"Angular authoritative Guide" reading notes--' mycontroller is not a function,got undefine '

Source: Internet
Author: User

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 '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.