.done的角等值的jQuerydone、jQuery

2023-09-13 04:09:40 作者:释然

我无法找到一个替代的解决方案是什么,我试图做的,可以说我有jQuery的这code:

  $得到'file.json',(重新) -  GT。   对K,V的重      TPL =< D​​IV> {{v.content}}< / DIV>中;      $'#container'.append TPL .done() - >     IM $ P $(PSS)的init() 

这是因为, .done 只有阿贾克斯之后执行code,但角度看起来别有一番像工作正常.done IM $ p $(PSS)的init()时被加载的内容不能重新初始化,因此也将是一个错误数据绑定..

下面是我尝试对角

  App.controller'SomeCtrl',($范围,$ HTTP) -  GT;   $ http.get('file.json')   .success(RES) -  GT;      $ scope.slides =水库   #what可能可能是在这里 
jQuery实现超简易ToDList页面

解决方案

您可以致电然后成功

  $ http.get('file.json')  .success(功能(数据){    的console.log(成功);  })  。然后(函数(){    的console.log('成功试);  }); 

下面是一个例如。

I cannot find an alternative solution to what I am trying to do, lets say I have this code in jquery:

$.get 'file.json', (re) ->
   for k, v in re
      tpl = "<div>{{v.content}}</div>";
      $ '#container'.append tpl
 .done () ->
     impress().init()

That works fine because, .done executes the code only after the ajax, but angular seems like don't have some like .done, and impress().init() cannot reinitialize when the content was loaded, therefore there will be a mistake on data binding..

Here is my attempt on angular

App.controller 'SomeCtrl', ($scope, $http) ->
   $http.get('file.json')
   .success (res) ->
      $scope.slides = res
   #what could possibly be in here

解决方案

You can call then after success:

$http.get('file.json')
  .success(function(data) {
    console.log('success');
  })
  .then(function() {
    console.log('success again');
  });

Here's an example.