How to run AngularJS example

前端 未结 3 628
借酒劲吻你
借酒劲吻你 2021-01-12 15:41

I\'ve done as described here: http://docs.angularjs.org/tutorial/step_00 but can\'t run the phonecat example as AngularJS. It runs like a bunch of html files. For example, t

相关标签:
3条回答
  • 2021-01-12 16:29

    The bootstrap part needs to be called after the element you're bootstrapping to is loaded. You can either put the bootstrap code at the end of your html, or you can use something like document ready from JQuery.

    0 讨论(0)
  • 2021-01-12 16:29

    I had the same problem. When loading angular with reguirejs, you have to remove the ng-app directive from the html and add it after calling angular.bootstrap(document, ['myApp']) like this:

    $(html).addClass('ng-app');

    Check this seed project out: https://github.com/tnajdek/angular-requirejs-seed specifically index.html and app/js/main.js

    0 讨论(0)
  • 2021-01-12 16:34

    Make sure your web server is running.

    If you are running node.js:
    1. Run node scripts\web-server.js to start the web server
    2. In your browser, navigate to http://localhost:8000/app/index.html

    If you are running some other http server: (I used WAMP for the AngularJS tutorial you listed):
    1. Make sure the /angular-phonecat repository was cloned into your wamp/www folder.
    2. Navigate in your browser to http://localhost:[port-number]/angular-phonecat/app.

    TIPS:
    To change directories using WINDOWS COMMAND LINE -

    cd /d c:\wamp\www
    

    To change directories using GIT BASH -

    $ cd /c/wamp/www 
    

    Additional note: In Git Bash, to display the directory you're currently in, use $ pwd

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