相关疑难解决方法(0)

将$ scope注入角度服务函数()

我有一个服务:

angular.module('cfd')
  .service('StudentService', [ '$http',
    function ($http) {
    // get some data via the $http
    var path = 'data/people/students.json';
    var students = $http.get(path).then(function (resp) {
      return resp.data;
    });     
    //save method create a new student if not already exists
    //else update the existing object
    this.save = function (student) {
      if (student.id == null) {
        //if this is new student, add it in students array
        $scope.students.push(student);
      } else {
        //for existing student, find this student using id
        //and update it.
        for (i …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angular-ui-router

106
推荐指数
4
解决办法
17万
查看次数

标签 统计

angular-ui ×1

angular-ui-router ×1

angularjs ×1