Angularjs ng控制器在主体元素中不工作
嗨,我已经开始学习Angular.js,这是我的第一个活动。这一切开始都很好,但当我将ng控制器添加到body元素时,它就不起作用了。我被困在这里了。你能告诉我这里有什么问题吗Angularjs ng控制器在主体元素中不工作,angularjs,Angularjs,嗨,我已经开始学习Angular.js,这是我的第一个活动。这一切开始都很好,但当我将ng控制器添加到body元素时,它就不起作用了。我被困在这里了。你能告诉我这里有什么问题吗 <html ng-app="helloWorldApp"> <head> <title>Angular Fundamentals</title> <link rel="stylesheet" href="https://maxcdn.bootstra
<html ng-app="helloWorldApp">
<head>
<title>Angular Fundamentals</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
</head>
<body ng-controller="firstController">
<div class="container">
<h1>AngularFundamentals</h1>
<h2> {{'Hello World from Angular'}}</h2>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
<script>
var helloWorldApp = angular.module('helloWorldApp',[]);
helloWorldApp.controller('firstController',[ '$scope', function(scope){
$scope.appName =" An App Name";
}]);
</script>
</body>
</html>
角度基础
角度基础
{{'Hello World from Angular'}}
var helloWorldApp=angular.module('helloWorldApp',[]);
helloWorldApp.controller('firstController',['$scope',函数(scope){
$scope.appName=“应用程序名称”;
}]);
您需要
<h2>{{appName}}</h2>
角度基础
{{appName}}
你好!你有什么错误吗?预期的行为是什么?什么意思它不起作用?键入:function(scope)
应该是function($scope)
。很抱歉,我的回复太晚了,我实际上错过了$sign,并且没有在{{}中写appName。谢谢Hanks Sajeetharan