为什么模型名称更改时功能不起作用

why the functionality not working when the model name is changed?

本文关键字:功能 不起作用 模型 为什么      更新时间:2023-09-26

我做了一个演示,效果很好。我会解释这个演示,我有一个文本字段和按钮。无论用户在文本字段上键入什么,点击按钮后,它都会在弹出屏幕中显示文本。当用户在弹出屏幕上写任何东西并提交按钮时,按下它就会在屏幕上显示

我的问题是,我采用了一个ng model="modaldata.passedValue"模型但是当我使用ng model="passedValue"时,我的功能停止了,为什么?我还将where is的每一个js都更改为passedValue,而不是modaldata。passedValuePlunkerhttp://plnkr.co/edit/PhXuubnDaYklqyoEdRtt?p=preview

这是代码

  $scope.modalClick = function() {
      //alert($scope.modaldata.passedValue);
      textValue = $scope.modaldata.passedValue;
      $rootScope.$broadcast('modalSubmit', {
        modalText: $scope.modaldata.passedValue // send whatever you want
      });
            $modalInstance.dismiss('cancel');
    }

此链接可能会有所帮助:

`http://stackoverflow.com/questions/17606936/angularjs-dot-in-ng-model`

您还需要将控制器中出现的所有$scope.modaldata.passedValue更改为$scope.passedValue。