将值传递给角度ui-bootstrap中的模态范围

时间:2015-07-13 15:14:37

标签: angularjs twitter-bootstrap

我有一个角度的表单设置,并使用ui-bootstrap进行提交完成之前出现的模式对话框。我的网站在Sharepoint中设置,并使用上下文来确定它们是否在网站的英语或西班牙语版本上,并显示正确的语言内容。我想将bool值IsInEnglish传递给模态以显示正确的<div>,但我找不到将此值传递给模态范围的解决方案。

        $scope.continue = function () { //this is off an ng-click on a button

        var modalInstance = $modal.open({
            templateUrl: '_layouts/Applications/VolunteerApp/modal/myModal.html',
            controller: 'vAppController'
        });

        modalInstance.opened.then(function () {
            $scope.modalIsInEnglish = IsInEnglish;

        });
    };

1 个答案:

答案 0 :(得分:3)

resolve的实例化对象添加$modal

    var modalInstance = $modal.open({
        templateUrl: '_layouts/Applications/VolunteerApp/modal/myModal.html',
        controller: 'vAppController',
        resolve: {
          myVar: function() {
            return someVal;
          }
        }
    });

然后传递someVal作为调用模态的函数的参数:

 $scope.continue = function (someVal)

要访问模态控制器中的someVal,请将其作为模态控制器的参数传递:

function myModalController($scope, someVal) { // do stuff }
相关问题