You need to put your controller in your module. Name your module in your ng-app tag (e.g. ng-app="myApp"). In the javascript code, you have to declare your module and put your controller in it.
Like this: <html *ng-app='myApp'*> <head> <!-- from Google Hosted Libraries --> <!-- https://developers.google.com/speed/libraries/devguide --> <script src=" https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> <!-- ///////////////////// --> <script> *angular.module('myApp', []).controller('CostCtrl', CostCtrl);* function CostCtrl($scope){ $scope.cost = 1000.1; } <!-- end of CostCtrl function--> </script> <!-- end of CostCtrl function script --> <!-- ///////////////////// --> </head> <body> <!-- DIV using ng-controller to connect to the CostCtrl function --> <div ng-controller="CostCtrl"> Cost: <input type="text" ng-model="cost" placeholder="cost" /> <p> <!-- the 'ng-model="cost" is what's being called here --> <!-- the "| currency" is the format --> This is your cost: {{cost | currency}} </p> </div> <!-- End of CostCtrl DIV --> <!-- ///////////////////// --> </body> </html> On Mon, Nov 2, 2015 at 7:04 PM, Mosno Al-Moseeki <[email protected]> wrote: > Hello fellow AngularJS coders, > I'm very new to this language and I'm taking a video course online, and > I'm running into a little problem with the "ng-controller" command. I have > heard that this command will not be used in the 2.0 version, but since > these teaching videos are using it, I need a help. > > So far the simple webpage being created was working just fine, until I > added "ng-controller" into the <body>, I tried looking online, but I > couldn't find anything helpful as of yet. > Hopefully someone here can show me what I'm doing wrong. Thank you. > Here is the source code. > > > > <html ng-app> > <head> > <!-- from Google Hosted Libraries --> > <!-- https://developers.google.com/speed/libraries/devguide --> > <script src=" > https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js > "></script> > <!-- ///////////////////// --> > > <script> > function CostCtrl($scope){ > $scope.cost = 1000.1; > } <!-- end of CostCtrl function--> > </script> <!-- end of CostCtrl function script --> > <!-- ///////////////////// --> > </head> > > <body> > <!-- DIV using ng-controller to connect to the CostCtrl function --> > <div ng-controller="CostCtrl"> > Cost: <input type="text" ng-model="cost" placeholder="cost" /> > <p> > <!-- the 'ng-model="cost" is what's being called here --> > <!-- the "| currency" is the format --> > This is your cost: {{cost | currency}} > </p> > </div> > <!-- End of CostCtrl DIV --> > <!-- ///////////////////// --> > > > </body> > </html> > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
