angularjs - What is wrong with this controller? -
the code below create controller within index.htmls <script></script>
doesn't work. wrong here? know can make work having separate app.js
, define there. interested know why doesn't work.
<!doctype html> <html data-ng-app> <head lang="en"> <meta charset="utf-8"> <title></title> </head> <body> <div data-ng-controller="skillscontroller"> <ul> <li data-ng-repeat="skill in skills">{{skill.name}} - {{ skill.stars}}</li> </ul> </div> <script> function skillscontroller($scope) { $scope.skills = [ { name: 'ruby', stars: 5 }, { name: 'java', stars: 10} ]; } </script> <script type="text/javascript" src="js/angular.js"></script> </body> </html>
use you
check link http://plnkr.co/edit/ukdbnq9ulk43m9xsq9yu?p=preview
<!doctype html> <html data-ng-app="myapp"> <head lang="en"> <meta charset="utf-8"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"> </script> </head> <body> <div data-ng-controller="skillscontroller"> <ul> <li data-ng-repeat="skill in skills">{{skill.name}} - {{ skill.stars}}</li> </ul> </div> <script> var app = angular.module("myapp",[]); app.controller('skillscontroller', function($scope){ $scope.skills = [ { name: 'ruby', stars: 5 }, { name: 'java', stars: 10} ]; }) </script> <script type="text/javascript" src="js/angular.js"></script> </body> </html>
Comments
Post a Comment