角度:将参数从控制器传递到工厂

今天很棒

很抱歉,如果有重复的话,但实际上在StackOverflow上的类似问题上找不到答案。

这是代码:

http://plnkr.co/edit/IsdYMgcIznQ667ols67b?p=preview

我想要的是line 19,我希望程序提醒我通过的号码,而当前它提醒我一个功能。数量应该是01,或2,这取决于哪一个条目删除(Remove Student)

oy屋

您的工厂方法接受两个参数,indexcallback以该顺序。

调用它时,只将其传递给一个函数。此函数接受indexcallback

相反,您需要将其传递给anindexancallback接受data

      $scope.removeStudent = function(index) {
          console.log(index);
          studentFactory.removeStudent(index, function(data){ // this is what's different
              console.log(data);
          });
      };

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章