引导模式内的AngularJS指令不工作
我在一个单页应用程序中使用AngularJS和Bootstrap。我正在以具有 验证码图像。不幸的是,表单无法正常工作。似乎没有一个ng指令是正确的 被跟踪。当代码不在模态中时,它可以正常工作。我的精简代码如下: 模式:引导模式内的AngularJS指令不工作,angularjs,twitter-bootstrap,Angularjs,Twitter Bootstrap,我在一个单页应用程序中使用AngularJS和Bootstrap。我正在以具有 验证码图像。不幸的是,表单无法正常工作。似乎没有一个ng指令是正确的 被跟踪。当代码不在模态中时,它可以正常工作。我的精简代码如下: 模式: <div class = "modal fade" id = "contact" role ="dialog"> <div class = "modal-dialog"> <div class = "modal-content">
<div class = "modal fade" id = "contact" role ="dialog">
<div class = "modal-dialog">
<div class = "modal-content">
<div class = "modal-header">
<h4>Email</h4>
</div>
<div class = "modal-body">
<div ng-controller="formController">
<div class = "table-responsive">
<table class="table table-striped table-bordered">
<tr ng-repeat="x in emails">
<td>{{ x.email }}</td>
</tr>
</table>
</div>
<form ng-submit = "processForm()" class="form-horizontal" role="form">
<div class="form-group form-group-sm">
<label for="email">Email address:</label>
<input type="email" name = "email" class="form-control" id="email" placeholder = "Enter Email">
</div>
<button type="submit" class="btn btn-default">Submit</button>
//display a captcha image with ability to refresh
<img class = "img-responsive" src="{{url}}" ng-click="refresh()">Refresh</img>
</form>
</div>
</div>
<div class = "modal-footer">
<a class = "btn btn-primary" data-dismiss = "modal">close</a>
</div>
</div>
</div>
你怎么打开你的手机?使用jQuery?这将不起作用,因为功发生在Angular的计算循环之外。尝试使用
$modal
服务弹出您的modal,它工作得非常完美:
$http({
...
}).success(function(data){
$modal.open({
'templateUrl': '...',
'controller': ...,
'resolve': ...
})
})
模板URL不仅可以指向外部资源,所以不要害怕额外的http调用。您可以将其与页内标记一起使用,只需
UPD:要回答您评论中的问题:
HTML:
OK有道理。要打开,我在导航栏和modalcode中使用。我们在Angular-UI中的等效方式。谢谢!这帮了大忙。
$http({
...
}).success(function(data){
$modal.open({
'templateUrl': '...',
'controller': ...,
'resolve': ...
})
})
<a data-ng-click="showPopup()">Show me!</a>
function Ctrl($scope, $modal){
$scope.showPopup = function(){
$modal.open({...});
}
}