gpt4 book ai didi

javascript - Angular js 没有在 Controller 上返回任何内容

转载 作者:行者123 更新时间:2023-12-02 15:48:56 25 4
gpt4 key购买 nike

我有一个简单的 Angular js 脚本,如下所示,它不会在页面中返回任何内容,并且控制台上也没有错误

index.html 就像

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<title>Angular Starting</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://code.angularjs.org/1.4.4/angular.min.js"></script>
<script src="app.js"></script>
<div ng-controller="MovieStore as store">
<h1 {{store.item.name}}></h1>
</div>
</body>
</html>

app.js就像

(function(){
var app = angular.module('myApp', []);
app.controller('MovieStore', function(){
this.item = movies;
});

var movies ={
name :'Cinema Paradiso',
price: 333,
}
})();

你能告诉我我做错了什么吗?

最佳答案

<div ng-controller="MovieStore as store">
<h1> {{store.item.name}}></h1>
</div>

(function(){
var app = angular.module('myApp', []);
app.controller('MovieStore', function($scope){
var movies ={
name :'Cinema Paradiso',
price: 333,
};
$scope.item = movies;
});

})();

关于javascript - Angular js 没有在 Controller 上返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32002320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com