我在我的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 –