angular-strap:在模态和旁边输入标签
angular-strap: input tag in modal and aside
我在angular-strap modal中使用了一个输入标签:
<div class="modal-body" >
<input type="text" placeholder="url" class="w-full" >
</div>
然后我在其中输入一些单词并使用 hide()
关闭模式。
但是下次打开modal的时候,发现上次输入的内容不见了。
我做错了什么吗?
我在这里做了一个工作 plunkr:plunkr. Take note of making kmlUrl an object key instead of a straight var: AngularStrap bs-select not updating ng-model
模式和页面现在彼此同步。模态加载 $scope.model.kmlUrl 中的任何内容,只要您在模态中更改它,页面就会更新。
<div ng-controller="TestModal">
<button type="button" ng-click="openTestModal()">
Open Modal
</button>
<div ng-cloak="">
{{ model.kmlUrl }}
</div>
</div>
<script type="text/ng-template" id="test-modal.html">
<input type="text" placeholder="url" ng-model="model.kmlUrl">
<div class="modal-footer">
<button type="button" ng-click="closeTestModal()">Close</button>
</div>
</script>
(function(){
angular.module('test', ['mgcrea.ngStrap']);
angular.module('test').controller('TestModal', function($scope, $modal){
var modal = $modal({
scope: $scope,
title: 'Test Modal',
contentTemplate: 'test-modal.html',
show: false
});
$scope.model = {
kmlUrl: 'https://www.amazon.com'
};
$scope.openTestModal = function(){
modal.show();
};
$scope.closeTestModal = function(){
modal.hide();
};
});
})();
我在angular-strap modal中使用了一个输入标签:
<div class="modal-body" >
<input type="text" placeholder="url" class="w-full" >
</div>
然后我在其中输入一些单词并使用 hide()
关闭模式。
但是下次打开modal的时候,发现上次输入的内容不见了。
我做错了什么吗?
我在这里做了一个工作 plunkr:plunkr. Take note of making kmlUrl an object key instead of a straight var: AngularStrap bs-select not updating ng-model
模式和页面现在彼此同步。模态加载 $scope.model.kmlUrl 中的任何内容,只要您在模态中更改它,页面就会更新。
<div ng-controller="TestModal">
<button type="button" ng-click="openTestModal()">
Open Modal
</button>
<div ng-cloak="">
{{ model.kmlUrl }}
</div>
</div>
<script type="text/ng-template" id="test-modal.html">
<input type="text" placeholder="url" ng-model="model.kmlUrl">
<div class="modal-footer">
<button type="button" ng-click="closeTestModal()">Close</button>
</div>
</script>
(function(){
angular.module('test', ['mgcrea.ngStrap']);
angular.module('test').controller('TestModal', function($scope, $modal){
var modal = $modal({
scope: $scope,
title: 'Test Modal',
contentTemplate: 'test-modal.html',
show: false
});
$scope.model = {
kmlUrl: 'https://www.amazon.com'
};
$scope.openTestModal = function(){
modal.show();
};
$scope.closeTestModal = function(){
modal.hide();
};
});
})();