angle.js – Bitte sagen Sie mir, warum mein HTML {{greeting.text}},Angular anstelle von Hello,Angular anzeigt
怪我咯
怪我咯 2017-07-04 13:44:55
0
4
1471

Entschuldigung, warum wird in meinem HTML-Code {{greeting.text}}, Angular anstelle von Hello, Angular
html

angezeigt?
<!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'
    };
}

Die Seite wird angezeigt als: {{greeting.text}},Angular

怪我咯
怪我咯

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

Antworte allen(4)
巴扎黑

自己看看官网链接描述就晓得了,你这函数也没调用啊

小葫芦

数据双向绑定,在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>

为情所困

在你的html文档中 ng-app 应该赋值(和js中定义的相同),
eg: ng-app="DemoApp"

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!