Reputation: 3510
**Error: [$parse:syntax] Syntax Error: Token 'Object' is unexpected, expecting []] at column 9 of the expression [[object Object]] starting at [Object]]. http://errors.angularjs.org/1.3.13/$parse/syntax?p0=Object&p1=is%20unexpected%2C%20expecting%20%5B%5D%5D&p2=9&p3=%5Bobject" "
.controller('AppCtrl', function($scope,$ionicPopup,$state ) {
$scope.myData = { prop1: "val1", prop2: "val2", prop3: "val3",prop4: "val4" };
var alertPopup =$ionicPopup.alert({
//templateUrl: '/templates/view.html'
template:
'<div class="row list-inset" ng-repeat= "(key, data) in '+$scope.myData+'" >'+
'<div class="col font_type2" >{{key}}</div>'+
'<div class="col font_type2" >{{data}}</div>'+
'</div>'
});
});
Upvotes: 1
Views: 753
Reputation: 3510
$scope so they can assign it as the scope property in the popup show options and scope of the popup for the data-binding.
.controller('AppCtrl', function($scope,$ionicPopup,$state ) {
$scope.myData = { prop1: "val1", prop2: "val2", prop3: "val3",prop4: "val4" };
var alertPopup =$ionicPopup.alert({
scope: $scope, // define the scope is here.
//templateUrl: '/templates/view.html'
template:
'<div class="row list-inset" ng-repeat= "(key, data) in '+$scope.myData+'" >'+
'<div class="col font_type2" >{{key}}</div>'+
'<div class="col font_type2" >{{data}}</div>'+
'</div>'
});
});
Upvotes: 1
Reputation: 2687
Your problem is concat the $scope.myData(Object) with String. When this ocurred Js interpret $scope.MyData as $scope.MyData.toString(), This returned "Object". For fix serializable $scope.MyData, after concat with String.
For serializable use: angular.element($scope.myData).serialize();
.controller('AppCtrl', function($scope,$ionicPopup,$state ) {
$scope.myData = { prop1: "val1", prop2: "val2", prop3: "val3",prop4: "val4" };
var alertPopup =$ionicPopup.alert({
//templateUrl: '/templates/view.html'
template:
'<div class="row list-inset" ng-repeat= "(key, data) in '+angular.element($scope.myData).serialize()+'" >'+
'<div class="col font_type2" >{{key}}</div>'+
'<div class="col font_type2" >{{data}}</div>'+
'</div>'
});
});
Upvotes: 1