Angularjs 角度带:在模态和旁侧输入标记
我在角带模式中使用输入标记:Angularjs 角度带:在模态和旁侧输入标记,angularjs,angular-strap,Angularjs,Angular Strap,我在角带模式中使用输入标记: <div class="modal-body" > <input type="text" placeholder="url" class="w-full" > </div> 然后我在其中键入一些单词,并使用hide()关闭模式。 但下一次打开模式时,我发现上次键入的内容已经消失了。 我做错什么了吗?我在这里做了一个工作提示:。请注意将kmlUrl设置为对象关键点而不是直线变量: 模式和页面现在彼此同步。模态加载$sc
<div class="modal-body" >
<input type="text" placeholder="url" class="w-full" >
</div>
然后我在其中键入一些单词,并使用hide()
关闭模式。
但下一次打开模式时,我发现上次键入的内容已经消失了。
我做错什么了吗?我在这里做了一个工作提示:。请注意将kmlUrl设置为对象关键点而不是直线变量: 模式和页面现在彼此同步。模态加载$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();
};
});
})();
开放模态
{{model.kmlUrl}
接近
(功能(){
角度模块('test',['mgcrea.ngStrap']);
角度。模块('test')。控制器('TestModal',函数($scope,$modal){
var modal=$modal({
范围:$scope,
标题:“测试模式”,
contentTemplate:“test modal.html”,
节目:假
});
$scope.model={
Kmlur:'https://www.amazon.com'
};
$scope.openTestModal=function(){
modal.show();
};
$scope.closeTestModal=函数(){
modal.hide();
};
});
})();
您没有将ng模型附加到该输入,如果您传入控制器,则每次打开该模型时,它都会重新初始化。我不希望它保持上次打开modalI时的值。我试过你说的,我在输入上使用ng模型,I$scope.kmlUrl=“xx”;我通过`kmlModal=$modal({scope:$scope,template:'tpl/kmlSelectModal.html',show:true})初始化modal;`但是kmlUrl没有与ng modal kmlUrlthanks一起工作很多,但是我使用的是angular strap项目,而不是ui bootstrapUpdated,代码来自,这是正确的库吗?