I am trying to user Angular JS with an ASP.NET Application.
I defined the app for my Main Page (Master Page) and it works fine. Now I run into multiple problems with other pages.
While I define a child page that consumes this master page, it has to use its own App. So
- Where can we define the app and controller attributes on the Child Page.
- If I define them on a DIV container it does not like it. It says -
Argument 'cityPageCtrl' is not a function, got undefined
In my master page, I have added the references as below :
<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>
In my child page, below is the code that I have to consume another ng application:
<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>
Below is what I have in my cityPage js file to define App for Angular.
var app = angular.module('cityPage', ['ui.bootstrap', 'templateModule', 'ngCookies']);
app.controller("cityPageCtrl", function($scope, $http, $modal, $cookies, $interval)