Angularjs 引导模式的自动关闭
我有一个引导模式,我想在加载所有值后关闭它。 下面是打开模式的代码-Angularjs 引导模式的自动关闭,angularjs,angular-ui-bootstrap,Angularjs,Angular Ui Bootstrap,我有一个引导模式,我想在加载所有值后关闭它。 下面是打开模式的代码- function open(){ console.log("open modal"); var modalInstance = $modal.open({ animation: true, templateUrl: 'views/view1.html', scope: $scope, }); }; view1.html <div c
function open(){
console.log("open modal");
var modalInstance = $modal.open({
animation: true,
templateUrl: 'views/view1.html',
scope: $scope,
});
};
view1.html
<div class="modal-header">
</div>
<div class="modal-body">
<div>
<progressbar class="progress-striped active" max="100" type='success' value="progress"></progressbar>
</div>
</div>
当scope变量progress的值变为100时,我想关闭模式,我该如何操作?控制器代码
...
function open(){
console.log("open modal");
var modalInstance = $modal.open({
animation: true,
controller: 'modalController'
templateUrl: 'views/view1.html',
scope: $scope,
});
}) // End of the actual page controller
.controller('modalController', function($scope, $modalInstance, $interval, $timeout) {
$scope.progress = $scope.$parent.progress;
$interval(function() { if ($scope.progress < 100) $scope.progress += 1 }, 50);
$scope.$watch(function() {return $scope.progress}, function() {
if ($scope.progress >= 100) {
$timeout(function() {
$modalInstance.close();
}, 1000)
}
})
})
在这里操作小提琴,控制器代码
...
function open(){
console.log("open modal");
var modalInstance = $modal.open({
animation: true,
controller: 'modalController'
templateUrl: 'views/view1.html',
scope: $scope,
});
}) // End of the actual page controller
.controller('modalController', function($scope, $modalInstance, $interval, $timeout) {
$scope.progress = $scope.$parent.progress;
$interval(function() { if ($scope.progress < 100) $scope.progress += 1 }, 50);
$scope.$watch(function() {return $scope.progress}, function() {
if ($scope.progress >= 100) {
$timeout(function() {
$modalInstance.close();
}, 1000)
}
})
})
在这里操作小提琴,控制器代码
...
function open(){
console.log("open modal");
var modalInstance = $modal.open({
animation: true,
controller: 'modalController'
templateUrl: 'views/view1.html',
scope: $scope,
});
}) // End of the actual page controller
.controller('modalController', function($scope, $modalInstance, $interval, $timeout) {
$scope.progress = $scope.$parent.progress;
$interval(function() { if ($scope.progress < 100) $scope.progress += 1 }, 50);
$scope.$watch(function() {return $scope.progress}, function() {
if ($scope.progress >= 100) {
$timeout(function() {
$modalInstance.close();
}, 1000)
}
})
})
在这里操作小提琴,控制器代码
...
function open(){
console.log("open modal");
var modalInstance = $modal.open({
animation: true,
controller: 'modalController'
templateUrl: 'views/view1.html',
scope: $scope,
});
}) // End of the actual page controller
.controller('modalController', function($scope, $modalInstance, $interval, $timeout) {
$scope.progress = $scope.$parent.progress;
$interval(function() { if ($scope.progress < 100) $scope.progress += 1 }, 50);
$scope.$watch(function() {return $scope.progress}, function() {
if ($scope.progress >= 100) {
$timeout(function() {
$modalInstance.close();
}, 1000)
}
})
})
在这里拉小提琴,我用一把小提琴编辑了我的文章,它应该会引导你前进。我用一把小提琴编辑了我的文章,它应该会引导你前进。我用一把小提琴编辑了我的文章,它应该会引导你前进。范围变量进度在第一个控制器中被修改,我想在更新的进展值。上面的代码是制作进度变量的副本并在第二个控制器中更改它。是的,我只是想模拟plunker中的情况。在您的情况下,您需要$watch$scope.$parent.progress。我相应地编辑了我的文章。范围变量progress在第一个控制器中被修改,我想监视更新的progress值。上面的代码是制作进度变量的副本并在第二个控制器中更改它。是的,我只是想模拟plunker中的情况。在您的情况下,您需要$watch$scope.$parent.progress。我相应地编辑了我的文章。范围变量progress在第一个控制器中被修改,我想监视更新的progress值。上面的代码是制作进度变量的副本并在第二个控制器中更改它。是的,我只是想模拟plunker中的情况。在您的情况下,您需要$watch$scope.$parent.progress。我相应地编辑了我的文章。范围变量progress在第一个控制器中被修改,我想监视更新的progress值。上面的代码是制作进度变量的副本并在第二个控制器中更改它。是的,我只是想模拟plunker中的情况。在您的情况下,您需要$watch$scope.$parent.progress。我据此编辑了我的文章。