2013-07-04 92 views
-1

我添加了一个指令的两个实例,但当它们在加载ajax请求时执行时,只有寄存器是ONE ajax请求,但在控制台中读取时有两个执行console.log但结果相同,但后端假设提供随机结果。指令实例共享Ajax结果,但我不希望它们

我希望假设有2个Ajax请求,但有不可能产生相同结果的机会,但它没有发生,它们共享结果。

这里是指令:

app.directive( '人文化',函数($ HTTP) {

return { 
    restrict:"EA", 
    template:'template stuff', 
    replace: true, 
    transclude: 'element', 
    scope:{ 
     key:"=", 
     activate:"=", 
     theme:"@" 
    }, 
    link:function (scope, elem, attrs) { 
     scope.question=""; 
     scope.placeholder=""; 
     scope.answer=""; 
     scope.key="";    
        var temp_key; 
     $http({ url:stage.ajax_url,method: "GET",params: {'action':'do_ajax','fn':'human'}}).success(function(data) { 
      scope.question=data.question; 
      scope.placeholder=data.placeholder; 
      temp_key=data.key; 
      console.log(temp_key); 
     }); 


    } 
} 

});

我在这里做错了什么?我需要指令的多个实例有不同的ajax结果...

回答

0

有没有什么错误的角度指令,它只是CHROME看到请求,因为相同,因此不执行它...只是绑定相同数据到每个阿贾克斯请求...