Angularjs $scope变量不';无法在指令中更新

Angularjs $scope变量不';无法在指令中更新,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我知道这是一个愚蠢的问题,但我就是不能让我的scope变量出现在指令的模板上。我有一个$scope.strans,它从$http请求获取数据。但是,$watch服务无法检测到指令链接中的更改并将其更新到模板 应用程序指令 app.directive('ptransaction',function(){ return{ restrict: 'EAC', template: '<h3>Did the client arrive? <% strans %><

我知道这是一个愚蠢的问题,但我就是不能让我的scope变量出现在指令的模板上。我有一个$scope.strans,它从$http请求获取数据。但是,$watch服务无法检测到指令链接中的更改并将其更新到模板

应用程序指令

app.directive('ptransaction',function(){
return{
    restrict: 'EAC',
    template: '<h3>Did the client arrive? <% strans %><span id="queue_no"> //doesn't update</span></h3>',
    link: function($scope){
        $scope.$watch('strans ',function(nv,ol){
            console.log("changes made"+nv); //cannot see changes in strans
        )};
    }
  };
});

为什么不在指令的隔离范围内使用双向绑定呢?类似于
scope:{strans:'='}
。尝试了它,但不起作用。您还可以查看父级的属性。类似于
$scope.$parent.$watch('strans',…)
监视字符串“strans”中的代码在变量名称后有一个空格。可能会尝试删除。您是否100%确定成功功能运行?请求是否有效?为什么不在指令的隔离范围内使用双向绑定?类似于
scope:{strans:'='}
。尝试了它,但不起作用。您还可以查看父级的属性。类似于
$scope.$parent.$watch('strans',…)
监视字符串“strans”中的代码在变量名称后有一个空格。可能会尝试删除。您是否100%确定成功功能运行?请求有效吗?
$scope.Call = function(trans_id){
    $http({
        url: $locationProvider + 'query_stransaction',
        method: "GET",
        params: { trans_id: trans_id }
    }).success(function (data){
        $scope.strans = data.transactions['q_number'];//Cannot update the strans in directive
    })
}