AngularJS引导模式范围值未显示

AngularJS引导模式范围值未显示,angularjs,Angularjs,我用的是角度引导模式 将填充termsText,并且作用域.productTerms不包含值。但是由于某种原因,当我在模式中输出{{productTerms}}时,值没有显示出来。为什么? js $scope.openProductTerms=函数(termsText){ $scope.productTerms=termsText尝试在HTML中使用{{{$parent.productTerms}} 根据我的经验,角度引导模式似乎创建了一个新的作用域。因此,通过首先引用$parent,您将能够获

我用的是角度引导模式

将填充
termsText
,并且
作用域.productTerms
不包含值。但是由于某种原因,当我在模式中输出
{{productTerms}}
时,值没有显示出来。为什么?

js

$scope.openProductTerms=函数(termsText){

$scope.productTerms=termsText尝试在HTML中使用
{{{$parent.productTerms}}


根据我的经验,角度引导模式似乎创建了一个新的作用域。因此,通过首先引用
$parent
,您将能够获得模型的值。

该模式有一个新的控制器,因此有一个新的作用域。 services.js

 angular.module('services',[]).
  factory('sharedService', function($rootScope) {
    var sharedService = {};   
    sharedService.value = null;

   sharedService.prepForBroadcast = function(value) {
       this.value = value;
       this.broadcastItem();
   };

   sharedService.broadcastItem = function() {
       $rootScope.$broadcast('shared');
   };

   return sharedService;
 });
controller.js

     $scope.openProductTerms = function (termsText) {
          sharedService.prepForBroadcast(termsText);
       var modalInstance = $modal.open({
       templateUrl: 'myModalTerms.html',
       controller: ModalInstanceCtrl
     });
     var ModalInstanceCtrl = function ($scope, $modalInstance,sharedService) {
        $scope.$on('shared', function() {
    $scope.productTerms = sharedService.value;
    });
       $scope.ok = function () {
          $modalInstance.dismiss('OK');
        };
     };
lastController.js

     $scope.openProductTerms = function (termsText) {
          sharedService.prepForBroadcast(termsText);
       var modalInstance = $modal.open({
       templateUrl: 'myModalTerms.html',
       controller: ModalInstanceCtrl
     });
     var ModalInstanceCtrl = function ($scope, $modalInstance,sharedService) {
        $scope.$on('shared', function() {
    $scope.productTerms = sharedService.value;
    });
       $scope.ok = function () {
          $modalInstance.dismiss('OK');
        };
     };

模态有一个新的控制器,因此有一个新的作用域。这可能会有帮助。当您打开模态时,您应该能够指定一个作用域。@Zack Argyle作用域为空。