Understanding Angular.js controller parameters

后端 未结 4 849
有刺的猬
有刺的猬 2020-12-07 07:57

I\'m just starting to learn Angular.js and I\'ve been looking at the project.js in the \"Wire up a Backend\" example on the Angular home page.

I\'m confused about th

4条回答
  •  醉话见心
    2020-12-07 08:38

    First off great job choosing this framework. It is the best. Those variables you see with the $ sign are injected and part of the standard framework. These services will make your life so much easier. The best way to think of controllers are they are script sheets. They help separate the code. Do not think of them as methods. Those variables you see such as $timeout & $scope are services that will come in handy as you need certain things done. All documentation for the framework is at http://docs.angularjs.org/api/ but I would start with this tutorial http://docs.angularjs.org/tutorial/ .

    The angularfire is not part of the framework. It is another service that leverages the framework in order to create a powerful real time distributed network. When you load the angularfirejs it comes with the service which is then injected as the parameter you see.

    To answer your second question, the parameters you pass could be anything so long as you make a corresponding service. Please refer to this to make your own parameter for controllers : http://docs.angularjs.org/guide/dev_guide.services.creating_services

    fbURL is just a variable that you can create and the code you placed in your question is simply the instruction on how to make it.

    Angularjs is not the type of framework you can learn by looking at what it offers. Simply because it offers it all. Everything you could possibly bring to make a great app. Instead you should focus on asking google how to solve your problem with angular.

    Also check out videos on youtube. You will find some great ones.

提交回复
热议问题