我尝试通过角度 HTTP 调用将一页 html 绑定到模型窗口,并且 ng-bind-html 标记还包括ngSanitize js 核心。但它在没有 HTML 元素的情况下工作。
我的代码:HTML
<div class="myModels" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" data-backdrop="true" ng-show="showModel">
<div class="modal-dialog" role="document" ng-bind-html = "ModelContent"></div>
</div>
控制器
$scope.Login = function(path){
$http.post('http:'+path).success(function(result){$scope.ModelContent = result;})
}
渲染 HTML:
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-model="">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">Login</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-10">
<label>User Name</label>
<input type="text" name="username" maxlength="10" class="form-control" ng-model="">
</div>
</div>
<div class="row">
<div class="col-md-10">
<label>Password</label>
<input type="password" name="password" maxlength="15" class="form-control" ng-model="">
</div>
</div>
</div>
<div class="modal-footer">
<button name="SignIn" class="btn btn-success pull-right">Log in</button>
</div>
</div>