【发布时间】:2015-08-16 05:04:23
【问题描述】:
我正在尝试通过 ASP.NET 应用程序使用 Angular JS。
我为我的主页(母版页)定义了应用程序,它运行良好。现在我在使用其他页面时遇到了多个问题。
虽然我定义了一个使用此母版页的子页面,但它必须使用自己的 App。所以
- 我们可以在哪里定义子页面上的应用和控制器属性。
- 如果我在 DIV 容器上定义它们,它不喜欢它。它说 -
Argument 'cityPageCtrl' is not a function, got undefined
在我的母版页中,我添加了如下参考:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="<%=ApplicationPath %>lib/js/ui-bootstrap-tpls-0.12.1.min.js"></script>
<script src="<%=ApplicationPath %>cust/js/templateApp.js"></script>
<script src="<%=ApplicationPath %>cust/js/mainPageApp.js"></script>
<script src="<%=ApplicationPath %>lib/js/parallax.min.js"></script>
在我的子页面中,下面是我必须使用另一个 ng 应用程序的代码:
<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
<script src="../cust/js/cityPageApp.js"></script>
<title ng-bind="'Restaurants in '+cityName+' | Restaurants'">Restaurants in your city serving online | Online Restaurnats</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyContent" runat="server">
<div ng-app="cityPage" ng-controller="cityPageCtrl">
</div>
</asp:Content>
以下是我在 cityPage js 文件中为 Angular 定义应用程序的内容。
var app = angular.module('cityPage', ['ui.bootstrap', 'templateModule', 'ngCookies']);
app.controller("cityPageCtrl", function($scope, $http, $modal, $cookies, $interval)
【问题讨论】:
标签: javascript jquery asp.net angularjs