Answer the question
In order to leave comments, you need to log in
Can't connect Angular controller. Where am I wrong?
Good afternoon. In the lessons I'm trying to learn how to use angular.
Project on ASP.NET MVC
Created a simple page
<!DOCTYPE html>
<html ng-app="appName">
<head>
<script src="~/main.js"></script>
</head>
<body ng-controller="mainController">
<h1>Angular Playground</h1>
{{message}}
<br />Total Length: {{message.length}}
</body>
</html>
function mainController($scope) {
$scope.message = "Hello, Michael";
}
angular
.module("appName", [])
.controller("mainController", mainController);
Answer the question
In order to leave comments, you need to log in
If you create a completely empty page with this code - it works.
If you run through the studio - it does not work.
<!DOCTYPE html>
<html ng-app="appName">
<head>
</head>
<body ng-controller="mainController">
<h1>Angular Playground</h1>
{{message}}
<br/>Total Length: {{message.length}}
</body>
<script>
function mainController($scope) {
$scope.message = "Hello, Michael";
}
angular
.module("appName", [])
.controller("mainController", mainController);
</script>
</html>
<html xmlns:ng="http://angularjs.org" >
everything worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question