1
我在單頁應用程序中使用AngularJS和Bootstrap。我正在以具有 驗證碼圖像的模式顯示錶單。不幸的是,表單不起作用。看起來,沒有任何的ng-指令是 被跟蹤。當代碼不在模式中時,代碼可以正常工作。我剝離下來的代碼如下:Bootstrap模式中的AngularJS指令不起作用
模態:
<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>
控制器:
myApp.controller('formController', function($scope,$http){
$scope.url = 'http://www.example.com/captcha/captcha.php?'+Math.random();
$scope.refresh = function() {
$scope.url = 'http://www.example.com/captcha/captcha.php?'+Math.random();
};
$scope.formData = {};
$scope.processForm = function()
{
$http({method: 'GET', url: 'http://www.example.com/emails.php?email='+$scope.formData.email}).success(function(response)
{$scope.emails = response;});
}
});
好的是有道理的。要打開我在導航欄中使用Contact和
@ user1884367,看我的編輯 – madhead 2014-09-25 23:44:06
謝謝!這幫了很多。 – user1884367 2014-09-26 20:30:54