What is wrong with this angularjs code? -
@{ layout = null; } <!doctype html> <html ng-app="exampleapp"> <head> <meta name="viewport" content="width=device-width" /> <script src="~/scripts/jquery-1.10.2.min.js"></script> <title>directives</title> <link href="~/content/bootstrap.css" rel="stylesheet" /> <style> .bold { font-weight:bold; } .red { color:red; } .green { color:blue; } </style> <script src="~/scripts/angular.js"></script> <script> angular.module("exampleapp", []).directive("unorderedlist", function (){ return { link: function (scope, element, attrs) { scope.data=scope[attrs["unorderedlist"]]; }, restrict: "m", template:"<ul><li ng-repeat='item in data'>{{item.price | currency}}</li></ul>" } }).controller("defaultctrl", function ($scope) { $scope.products = [{ name: "apples", category: "fruit", price: 1.20, expiry: 10 },{ name: "bananas", category: "fruit", price: 2.42, expiry: 7 },{ name: "pears", category: "fruit", price: 2.02, expiry: 6 } ]; $scope.incrementprices = function () { for(var i=0;i<$scope.products.length;i++) { $scope.products[i].price++; } }; }); </script> </head> <body ng-controller="defaultctrl" > <h3>fruit</h3> <!-- directive:unordered-list products --> </body> </html> i want apply directive comment . did not work. question how apply angularjs directive comment while using template , link directive definitions while using restrict definition.
Comments
Post a Comment