【问题标题】:use a bootstrap modal without making a seperate controller使用引导模式而不制作单独的控制器
【发布时间】:2015-06-26 01:25:45
【问题描述】:

我正在使用bootstrap modal

Controller.js -

    $scope.open = function() {
    var modalInstance = $modal.open({
        animation: true,
        templateUrl: 'views/template.html',
        controller: 'controller2',
        resolve: {
            items: function() {
                return $scope.values;
            }
        }
    });
    modalInstance.result.then(function(values) {
        $scope.new_value = values;
    }, function() {

    });
};

我不想创建新控制器,因为模式应该显示当前控制器中不断变化的值。如果我模态在同一个控制器中,我应该通过什么来代替 controller2?

【问题讨论】:

    标签: angularjs angular-ui-bootstrap bootstrap-modal


    【解决方案1】:

    您可以使用范围选项而不是控制器:

    $scope.open = function() {
        var modalInstance = $modal.open({
            animation: true,
            templateUrl: 'views/template.html',
            scope: $scope,
            resolve: {
                items: function() {
                    return $scope.values;
                }
            }
    });
    modalInstance.result.then(function(values) {
            $scope.new_value = values;
        }, function() {
    
        });
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-10
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      相关资源
      最近更新 更多