What is the cause for “angular is not defined”

前端 未结 3 1181
Happy的楠姐
Happy的楠姐 2020-11-27 19:09

I\'m following the video tutorials on egghead.io but while trying to follow his example when he created a factory (see video here) I keep getting \"angular is not defined\"

相关标签:
3条回答
  • 2020-11-27 19:12

    I had the same problem as deke. I forgot to include the most important script: angular.js :)

    <script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
    
    0 讨论(0)
  • 2020-11-27 19:16

    You have not placed the script tags for angular js

    you can do so by using cdn or downloading the angularjs for your project and then referencing it

    after this you have to add your own java script in your case main.js

    that should do

    0 讨论(0)
  • 2020-11-27 19:20

    You have to put your script tag after the one that references Angular. Move it out of the head:

    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript" src="main.js"></script>
    

    The way you've set it up now, your script runs before Angular is loaded on the page.

    0 讨论(0)
提交回复
热议问题