1

**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>'

                      });
});
4
  • In template use $compile, as template:$compile("<content>"), and in $scope.myData use scape, "JSON.stringify($scope.myData)" Commented Oct 5, 2015 at 13:07
  • Hi Emir, i am using JSON.stringify($scope.myData) in ng-repeat tag but not work. Commented Oct 5, 2015 at 13:16
  • 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 Commented Oct 5, 2015 at 13:25
  • For serializable use: angular.element($scope.myData).serialize(); Commented Oct 5, 2015 at 13:27

2 Answers 2

1

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>'
    });
});
Sign up to request clarification or add additional context in comments.

6 Comments

ng-repeat is not working here "Error: [$parse:syntax] Syntax Error: Token 'Object' is unexpected, expecting []] at column 10 of the expression [[[object Object]]] starting at [Object]]]. errors.angularjs.org/1.3.13/$parse/…" "<!-- ngRepeat: (key, data) in [[object Object]] -->" "bject%5D%5D&p4=Object%5D%5D
serialize is not a method of angularJs. angular provide serializeToString().
serialize is method jquery. Try print console.log(angular.element($scope.myData).serialize())
I am not using JQuery. only used in Ionic and angularJS.so this situation serialize is not work. bt I am get the answer, why my ng-repeat was not work? bcz myData's value is empty in ionicPopup so define $ionicPopup.alert in scope: $scope=scope;
Print this in console: '<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>'
|
1

$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>'

                      });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.