This is the first pit that was encountered while watching the Angular authoritative guide, and the example in the book was this:
<!DOCTYPE HTML><HTMLNg-app> <Head> <Scriptsrc= "Https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></Script> </Head> <Body> <DivNg-controller= "Mycontroller"> <H1>Hello {{Clock}}!</H1> </Div> <Scripttype= "Text/javascript"> functionMycontroller ($scope, $timeout) {varUpdateclock= function() {$scope. Clock= NewDate (); $timeout (function() {updateclock (); }, +); }; Updateclock (); }; </Script> </Body></HTML>
The book used in the angular is 1.2 version, I use 1.4 version, after running an error, said ' Mycontroller is not a function,got undefine '.
Check it out, this problem occurs in the angular1.3 is forbidden to register the controller directly on the root, the reason is that the root node (rootscope) is not hung on the redundant content, the original code as follows to modify the normal operation:
<!DOCTYPE HTML><HTMLNg-app= ' first '> <Head> <Scriptsrc= "Http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></Script> </Head> <Body> <DivNg-controller= "Mycontroller"> <H1>Hello {{Clock}}!</H1> </Div> <Scripttype= "Text/javascript"> varFirstmoudle=Angular.module (' First',[]); Firstmoudle.controller ('Mycontroller', Mycontroller); functionMycontroller ($scope, $timeout) {varUpdateclock= function() {$scope. Clock= NewDate (); $timeout (function() {updateclock (); }, +); }; Updateclock (); }; </Script> </Body></HTML>
"Angular authoritative Guide" reading notes--' mycontroller is not a function,got undefine '