我使用的是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