0

I am unable to get binding to work. I am not sure what I am doing wrong. When I attempt to display the value of the header on the page, the page generated is "{{name}}" instead of "My App".

Here is the code:

<!DOCTYPE HTML>
<html ng-app="appModule">
<head ng-controller="appController">
    <meta name="viewport" content="width=device-width" />
    <title>Home</title>

    <script src="~/Views/Scripts/angular.js"></script>
    <script>
        /// <reference path="~/Views/Scripts/angular.js" />

        var appModule = angular.module("appModule", []);

        appModule.controller("appController", function ($scope)
        {
            $scope.name = "My App";
        });
    </script>
</head>
<body ng-controller="appController">
    <div>
        <h1>{{name}}</h1>
    </div>
</body>
</html>
1
  • 1
    You should avoid using a tilde in your URL. Commented Jul 13, 2014 at 18:01

1 Answer 1

1

I got it working by loading angular directly from google CDN, so the error might be in the loading of angular

See here: http://jsfiddle.net/9JyX6/

<html ng-app="appModule">
<head ng-controller="appController">
    <title>Home</title>

    <script>
        /// <reference path="~/Views/Scripts/angular.js" />

        var appModule = angular.module("appModule", []);

        appModule.controller("appController", function ($scope)
        {
            $scope.name = "My App";
        });
    </script>
</head>
<body ng-controller="appController">
    <div>
        <h1>{{name}}</h1>
    </div>
</body>
</html>
Sign up to request clarification or add additional context in comments.

1 Comment

Updated script tag syntax using "../": <script src="../Views/Scripts/angular.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.