Javascript 使用AngularJS中控制器的值预填充引导模式输入
我想用ng模型数据在引导模式中预先填充表单,所以我尝试了一些方法,但没有成功。这是我的密码。我尝试添加解析函数,使$scope对象返回到我的modalService,但它没有像我预期的那样工作。有人能帮我吗?谢谢:首先,您的Plunk中没有任何型号,因此不会显示任何内容 要在模型内显示数据,您需要遵循与在其他位置显示数据相同的过程Javascript 使用AngularJS中控制器的值预填充引导模式输入,javascript,angularjs,twitter-bootstrap,Javascript,Angularjs,Twitter Bootstrap,我想用ng模型数据在引导模式中预先填充表单,所以我尝试了一些方法,但没有成功。这是我的密码。我尝试添加解析函数,使$scope对象返回到我的modalService,但它没有像我预期的那样工作。有人能帮我吗?谢谢:首先,您的Plunk中没有任何型号,因此不会显示任何内容 要在模型内显示数据,您需要遵循与在其他位置显示数据相同的过程 <div class="modal fade"> <div class="modal-dialog"> <div class
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
如果您希望在modal中使用表单,那么ng模型是适合您的,您可以这样使用它:
<form name="testForm" ng-controller="ExampleController">
<input ng-model="name" name="anim" class="my-input"
aria-describedby="inputDescription" />
</form>
这将双向地将模型中的name属性绑定到输入,这反过来将预填充输入字段。您可以阅读有关ng模型的更多信息您好,我创建了一个服务,用于在我的主控制器和modalcontroller之间共享数据,但现在我只能在我的modalService中传播modalOptions。若您尝试此操作并单击编辑按钮,您将看到预填充的inputbox,但modalOptions消失了。如果您在script.js中注释第97行并取消注释第98行,它将向您显示modalOptions定义的模态,但现在它当然不会填充我的输入框。你有办法解决我的问题吗?你的Plunkr链接哪儿都去不了。
<form name="testForm" ng-controller="ExampleController">
<input ng-model="name" name="anim" class="my-input"
aria-describedby="inputDescription" />
</form>