javascript - Angularjs doesnot print from function -
<!doctype html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <body> <div ng-app="canerapp" ng-controller="canerctrl"> <br> {{text}}f </div> <script type="text/javascript"> var app = angular.module('canerapp', []); app.controller('canerctrl', function($scope){ $scope.text ="ff"; }); </script> </body> </html>
this works , prints
fff
as can see here
http://plnkr.co/edit/gp2ncc38jpsabqfacgkb?p=preview
but doesnot work
<!doctype html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <body> <div ng-app="myapp" ng-controller="mycontroller"> <br> {{text}}f <br> {{text}}fh </div> <script type="text/javascript"> var app= angular.module('myapp',[]); app.controller('mycontroller', function($scope){ $scope.text="afasfa"; }); </script> </body> </html>
can seen here https://plnkr.co/edit/1i90i5andra6oumzry65?p=preview
they totally same except controller , app nmes.
i spent 1 hour couldnot figure out. , couldnot find online error finders validate if true.
actually difference in first code using http
protocol plnkr , in second code using https
plnkr , using http
protocol angular library.
so change protocol https
in script tag.
thanks @ashu jha plnk https://plnkr.co/edit/ivusqbpop2864xp9s81s?p=preview
Comments
Post a Comment