我在我的angualr js文件中有一个数组对象,它试图控制台在js文件中显示结果。当我试图在html文件中使用同一个对象时,它显示为空。数组对象在显示为空的同时读取子页面时显示为空html页面 - angular JS
这是到目前为止我的代码:它打印为{}
任何帮助,说我要去哪里错了对话框上
$scope.testarray=[];
$rootScope.$on('rootScope:testarray', function() {
$scope.testarray = UserDataService.testarray;//this is read from a api service
console.log("test"+ $scope.testarray)
//prints on the console as :: test[object Object]
$scope.showdialog('testdialog.html');
});
$scope.showdialog= function (id) {
$mdDialog.show({
scope: $scope.$new(),
templateUrl: id
});
}
testdialog.html
<div ng-controller="testCtrl"> <!-- same controller as the above function!-->
<div >
<div layout="column" layout-padding flex>
<b> <span>{{ testarray}}</span></b>
</div>
</div>
</div>
。我没有看到使用问题。
u能提供样本数据的plunker –