1

Here i try to Angular setup in html page for that i wrote simple code as Below

MyApp.js

/// <reference path="angular.js" />
var app = angular.module('MyApp', [])
debugger;
app.controller('HomeCtrls', function ($scope) {
    $scope.msg = "This is MyApp....";
})

Master.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head ng-app="MyApp">
    <title></title>
    <script src="../../Script/angular.js"></script>
    <script src="../../Script/MyApp.js"></script>
</head>
<body ng-controller="HomeCtrls">
    {{msg}}
</body>
</html>

Here why my msg is not Loading This is MyApp....

4
  • is there any errors in the console Commented May 22, 2017 at 6:07
  • no error its just display as {{msg}} Commented May 22, 2017 at 6:10
  • make sure your script files are loading. go to browser console and check the network tab Commented May 22, 2017 at 6:11
  • all these are loading in networktab Commented May 22, 2017 at 6:12

2 Answers 2

4

ng-app inject wrong place. Not <head ng-app="MyApp">, Inject html or body or div tag as per your web application need.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../../Script/angular.js"></script>
    <script src="../../Script/MyApp.js"></script>
</head>
<body ng-app="MyApp" ng-controller="HomeCtrls">
    {{msg}}
</body>
</html>
Sign up to request clarification or add additional context in comments.

2 Comments

that's a nice catch!
Welcome @Joe Pill
0

the problem is with your angular script, is not loaded, check your path, you can use the CDN also :

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.