我使用的是angularJs,twitter引导与asp.net mvc4。我没有使用角带。我试图在bootstrap模式下加载部分视图。局部视图包含角码。角码不工作在引导模式
这里是我的代码,其中我打电话的引导模式:
@model IEnumerable<IMS.Domain.Model.GetAllRequisitions_Result>
@{
ViewBag.Title = "Requisition List";
Layout = "~/Views/Shared/MasterPage.cshtml";
}
<a href="#myModal" role="button" class="btn btn-primary" id="modalluncher" data-toggle="modal" onclick="loadCreateForm()"> Launch demo modal </a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
</div>
</div>
<script type="text/javascript">
function loadCreateForm() {
var content = '@Url.Action("Create", "Requisition", new { area = "IMS" })';
$('div.modal-body').load(content);
}
</script>
这里是我的代码为 '征用' 控制器 '创建' 行动:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div ng-app="">
<label>Sample: <input type="text" ng-model="sample" /></label>
<br />
<label>Show Value: {{sample}}</label>
</div>
<div class="ContainerRowButton">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
对于ng-model =“sample”,当我试图按{{sample}}显示数据时,它保持{{sample}}。这就像我的'创建'行动没有得到angularJs。
我已经在'MasterPage.cshtml'中提供了所有必要的脚本。我MasterPage.cshtml包含:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/others")
这里是我的 'Bundle.config.cs' 文件的代码:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/others").Include(
"~/Content/bootstrap/js/bootstrap.js",
"~/Scripts/jquery.dataTables.js",
"~/Scripts/dataTables_bootstrap.js",
"~/Scripts/bootstrap-dropdown.js",
"~/Scripts/jquery.dataTables.columnFilter.js",
"~/Scripts/Custom/CustomScript.js",
"~/Scripts/jquery.validationEngine-en.js",
"~/Scripts/jquery.validationEngine.js",
"~/Scripts/angular.js"
));
什么错我在干嘛?需要帮助...
'loadCreateForm()'做了什么?你是用ajax调用加载的吗? –
你正在注入你的模态html页面加载完成后,你的模态html没有绑定到$范围。你需要用'$ compile(html)($ scope)'来编译你的html,这样才能工作。 – Muctadir