.done的角等值的jQuery [英] Angular equivalent of .done in jquery

查看:105
本文介绍了.done的角等值的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到一个替代的解决方案是什么,我试图做的,可以说我有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可能可能是在这里


解决方案

您可以致电然后成功

  $ 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.

这篇关于.done的角等值的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆