Reputation: 7301
I am so new in Angularjs .I create a mvc project in VS2015.In the layout page i added these files:
<html data-ng-app="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/angular.min.js"></script>
</head>
<body>
@RenderBody()
</body>
</html>
I added a java file called home-Index.js to js folder :
//home-index.js
function homeIndexController() {
alert("hello word");
}
I have another view called index
and here you can see the content
@{
ViewBag.Title = "Home Page";
}
<script src="~/js/home-Index.js"></script>
<div data-ng-controller="homeIndexController">
</div>
I am expecting to see the alert hello world
but nothing happens.Why ?
Upvotes: 0
Views: 582
Reputation: 17064
If you passed version 1.3 you have to define your module as Ozrix stated in the comments. In addition, you also have to attach your controller to it:
var myApp = angular.module('myApp',[]);
myApp.controller('homeIndexController', homeIndexController);
Upvotes: 4