【发布时间】:2015-09-17 15:51:49
【问题描述】:
我想通过点击“打开我的链接”打开另一个模式
下面提供了代码和sn-p。
script.js
angular.module('myApp', ['ui.bootstrap','angular-drawer']);
angular.module('myApp').controller('mainCtrl', function ($scope, $modal, $log) { $scope.open = 函数 () {
$modal.open({
templateUrl: 'myModalContent.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, $log, user) {
$scope.user = user;
$scope.submit = function () {
$log.log('Submiting user info.');
$log.log(user);
$modalInstance.dismiss('cancel');
}
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
},
resolve: {
user: function () {
return $scope.user;
}
}
});
};
$scope.open1 = function () {
$modal.open({
templateUrl: 'myModalContent1.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope,open, $modalInstance, $log, user) {
$scope.opensignup=function () {
$modalInstance.dismiss('cancel');
};
$scope.user = user;
$scope.submit = function () {
$log.log('Submiting user info.');
$log.log(user);
$modalInstance.dismiss('cancel');
}
$scope.cancel11 = function () {
$modalInstance.dismiss('cancel');
};
},
resolve: {
user: function () {
return $scope.user;
}
}
});
};
});
html
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3>I'm a modal!</h3>
</div>
<form ng-submit="submit()">
<div class="modal-body">
<label>User name</label>
<input type="text" ng-model="user.user" />
<label>Password</label>
<input type="password" ng-model="user.password" />
</div>
<a ng-click="opensignup()">Open me!</a>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel11()">Cancel</button>
<input type="submit" class="btn primary-btn" value="Submit" />
</div>
</form>
</script>
<script type="text/ng-template" id="myModalContent1.html">
<div class="modal-header">
<h3>I'm a modal11111111111111111111111!</h3>
</div>
<form ng-submit="submit()">
<div class="modal-body">
<label>User name</label>
<input type="text" ng-model="user.user" />
<label>Password</label>
<input type="password" ng-model="user.password" />
</div>
<button class="btn" ng-click="cancel()">Open me!</button>
<div class="modal-footer">
<a class="btn btn-warning" ng-click="cancel()">Cancel</a>
<input type="submit" class="btn primary-btn" value="Submit" />
</div>
</form>
</script>
<button class="btn" ng-click="open()">Open me!</button>
【问题讨论】:
-
getbootstrap.com/javascript/#modals 说:不支持多个打开模式
-
太棒了..您描述了您想做的事情,但没有说明您遇到的问题或任何代码。您遇到的具体问题是什么?
-
如果您需要,例如,从模式“登录”更改为模式“忘记密码”,您可以在某些块中使用 ng-if/ng-show/ng-hide,在相同的模态,或关闭当前模态并打开下一个模态。
-
没有办法做到这一点吗?我希望通过单击“打开我”链接注册页面以模态打开@JoaozitoPolo
-
没有办法做到这一点吗?我希望通过单击“打开我”链接注册页面以模态打开@charlietfl
标签: angularjs angular-ui-bootstrap