AngularJS JSON_CALLBACK not working with ng-repeat -
i'm trying make ng-clickable menu using ng-repeat. use ngresource call rest server. when menu done in pure html (ul/li), works when done ng-repeat, data set callback not updated in html view.
maybe simple example more clear :
- simple button working
- html menu working
- ng-repeat call server done nothing happens
did miss ?
thanks in advance
ps : tried make jsfiddle couldn't make work...
html page :
<!doctype html> <html> <head> <script src="http://code.angularjs.org/1.0.7/angular.min.js"></script> <script src="http://code.angularjs.org/1.0.7/angular-resource.min.js"></script> <script src="js/date.js"></script> </head> <body> <div ng-app="app"> <div ng-controller="controller"> <h1>{{ date.time }}</h1> <h1>{{ date.milliseconds_since_epoch }}</h1> <hr> <button ng-click="fetchdate()">fetch</button> <hr> <div><ul><li><a>html menu</a> <ul><li><button ng-click="fetchdate()">fetch</button></li></ul> </li> </ul> </div> <hr> <div><ul><li ng-repeat="menuitem in menu.menuitems"><a>{{menuitem.label}}</a> <ul><li ng-repeat="submenuitem in menuitem.submenuitems"> <button ng-click="fetchdate()">fetch</button> </li> </ul> </li> </ul> </div> </div> </div> </body> </html>
angular controller (date.js) :
angular.module('app', ['ngresource']); controller = function ($scope, $resource) { $scope.menu = {'menuitems': [ {'label': 'menu1', 'submenuitems': [ {'label': 'sub1'} , {'label': 'sub2'} ] } , {'label': 'menu2', 'submenuitems': [ {'label': 'sub1'} , {'label': 'sub2'} ] } ] }; $scope.date = $resource('http://date.jsontest.com/', { alt: 'jsonp', callback: 'json_callback' }, { get: { method: 'jsonp' } } ); $scope.fetchdate = function () { this.date = this.date.get(); }; };
Comments
Post a Comment