Javascript 角度指令的多个实例将返回不同的值。那么如何在单个事件中获取所有值呢

Javascript 角度指令的多个实例将返回不同的值。那么如何在单个事件中获取所有值呢,javascript,angularjs,Javascript,Angularjs,我有一个问题,我创建了一个自定义指令,其中创建了一个文本框。我在一个模板上使用了多次。问题是,当我在一个文本框上更改时,我希望获得所有字段(或指令)的值 这是指令视图模板 <div><input type="text" name="sender" ng-model="cstmfld" value="" ng-change="sendResponse()" /></div> <script> angular.module('myApp').d

我有一个问题,我创建了一个自定义指令,其中创建了一个文本框。我在一个模板上使用了多次。问题是,当我在一个文本框上更改时,我希望获得所有字段(或指令)的值


这是指令视图模板

<div><input type="text" name="sender" ng-model="cstmfld" value="" ng-change="sendResponse()" /></div>

<script>
 angular.module('myApp').directive('mydirective', function(){
     return {
       restrict: 'EA',
       replace: true,
       transclude: true,
       scope: {
        label: '@',
        input: '=',
        currencyList: '=',
        fieldModel:'='
       },
       templateUrl: 'views/field.html',
       controller: function($scope, $element, $attrs, $http){
          $scope.sendResponse = function(){
             //do something so i get both filed value
          }
       }
    }
 });
</script>

角度.module('myApp')。指令('mydirective',函数(){
返回{
限制:“EA”,
替换:正确,
是的,
范围:{
标签:“@”,
输入:'=',
currencyList:“=”,
字段模型:'='
},
templateUrl:'views/field.html',
控制器:函数($scope、$element、$attrs、$http){
$scope.sendResponse=函数(){
//做点什么,这样我就能得到两个文件值
}
}
}
});

我是否犯了任何错误或是否可能

您的意思是说,如果您在一个指令中更改,则更改将反映在所有指令中?否,其他字段有一些值,我想用一个值的更改来计算该值。我是用一个全局变量做的,但我需要一些动态的解决方案。你能做一个简单的解释吗?
<div><input type="text" name="sender" ng-model="cstmfld" value="" ng-change="sendResponse()" /></div>

<script>
 angular.module('myApp').directive('mydirective', function(){
     return {
       restrict: 'EA',
       replace: true,
       transclude: true,
       scope: {
        label: '@',
        input: '=',
        currencyList: '=',
        fieldModel:'='
       },
       templateUrl: 'views/field.html',
       controller: function($scope, $element, $attrs, $http){
          $scope.sendResponse = function(){
             //do something so i get both filed value
          }
       }
    }
 });
</script>