Best way to invoke Rest APIs from angularjs?

后端 未结 6 420
遇见更好的自我
遇见更好的自我 2020-12-28 18:44

From where should REST API request be invoked from angular js?

I.e. from controller, module, service, factory. I am totally confused that what should be the right w

6条回答
  •  猫巷女王i
    2020-12-28 19:18

    If your going to use that REST API call in more than one controller it is best to create a service that is injected as a dependency into the controllers that need it. Like already mentioned, you want to use $resource to handle RESTful APIs.

    index.html:

    
    
    
    
    
    
    • {{game.GameName}}

    Reference: AngularJS: $resource

提交回复
热议问题