Javascript 如何从angular js中的其他标记属性获取模型?

Javascript 如何从angular js中的其他标记属性获取模型?,javascript,html,angularjs,Javascript,Html,Angularjs,我有以下html <input class="form-check-input" data-fieldId="79" ng-model="test1" type="text" name="test1"> <input class="form-check-input" data-fieldId="80" ng-model="test2" type="text" name="test2"> 我在控制器中有数据字段ID。我需要通过字段id及其角度值来找到输入元素。我

我有以下html

 <input class="form-check-input" data-fieldId="79" ng-model="test1"  type="text" name="test1">


<input class="form-check-input" data-fieldId="80" ng-model="test2"  type="text" name="test2">

我在控制器中有数据字段ID。我需要通过字段id及其角度值来找到输入元素。

我不完全理解您的问题,但您可以试试这个

<!DOCTYPE html>
        <html lang="en">
        <head>

            <title>Ristorante Con Fusion: Menu</title>
              <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
              <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>

              <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.6/ui-grid.min.js"></script>
              <style>
              .grid {
      width: 500px;
      height: 250px;
    }
              </style>
        </head>
        <body>


      <div ng-app="myApp" ng-controller="userController">
        <input class="form-check-input" data-fieldId="79" ng-model="test1" ng-change="textchanged()" type="text" name="test1">


        <input class="form-check-input" data-fieldId="80" ng-model="test2" ng-change="textchanged()" type="text" name="test2"> {{result1}} {{result2}}
        </div>

            <script>
       var app = angular.module('myApp', ["ngRoute"]);

         app.controller('userController', function ($scope) {

         $scope.textchanged = function(){
          $scope.result1 = $scope.test1;
          $scope.result2 = $scope.test2
         }

        });
            </script>
        </body>
        </html>

为什么使用ng change没有必要这么做??我只需要从数据字段中找出输入元素。输入元素表示您在文本框中给出的数据。是的,需要找到元素及其值,模型是动态的。当您在文本框中输入值时,angular应该知道该值已更改,或者您应该为其编写监视程序。这就是书面文本改变事件的原因