angular.js - Please tell me why my html displays {{greeting.text}},Angular instead of Hello,Angular
怪我咯
怪我咯 2017-07-04 13:44:55
0
4
1546

Excuse me why my html displays {{greeting.text}},Angular instead of Hello,Angular
html

<!DOCTYPE html>
<html ng-app>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/angular.js"></script>
    <script src="js/HelloAngular-MVC.js"></script>
</head>
<body>
    <p ng-controller="HelloAngular">
        <p>{{greeting.text}},Angular</p>
    </p>
</body>
</html>

JS

function HelloAngular($scope) {
    $scope.greeting ={
        text:'hello'
    };
}

The page is displayed as: {{greeting.text}},Angular

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
巴扎黑

Just look at the official website link description and you will know. You didn’t call this function either

小葫芦

Two-way data binding, tutorial on angular

三叔

例子
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script src="http://cdn.static.runoob.com/...

<body>

<p ng-app="myApp" ng-controller="myCtrl">

名: <input type="text" ng-model="firstName">

姓: <input type="text" ng-model="lastName">



姓名: {{firstName + " " + lastName}}

</p>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {

$scope.firstName = "John";
$scope.lastName = "Doe";

});
</script>

</body>
</html>

为情所困

In your html document ng-app should be assigned a value (the same as defined in js),
eg: ng-app="DemoApp"

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template