gpt4 book ai didi

javascript - Angular 没有显示我的记录

转载 作者:行者123 更新时间:2023-12-03 05:32:18 26 4
gpt4 key购买 nike

我是 Angular 新手,尝试做一项练习,但结果未显示在浏览器上。

(function() {

var app = angular.module('bus', []);

app.controller('BusContorller', function() {
this.busbarnd = basname;
});

var basname = {
name: 'tata',
yearprod: 2000,
}

})();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!-- container -->
<div class="container" ng-app="bus">
<!-- row -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<!-- Call controller -->
<div ng-controller="BusContorller as bus">
<p>Bus name : {{bus.busbarnd.name}}</p>
</div>
<!--// Call controller -->
</div>
</div>
<!-- // row end -->
</div>
<!-- // container -->

请让我知道我做错了什么。我想我在调用 Controller 时犯了错误。

最佳答案

尝试如下

<!DOCTYPE html>
<html ng-app="bus">

<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>
<script src="app.js"></script>
</head>
<script>
var app = angular.module('bus',[]);

app.controller('BusContorller', function($scope){
$scope.busbarnd = $scope.basname;

$scope.basname = {
name: 'tata',
yearprod: 2000,
}
});



</script>

<body ng-controller="BusContorller">
<div ng-controller="BusContorller as bus">
<p>Bus name : {{busbarnd.name}}</p>
</div>
</body>

</html>

关于javascript - Angular 没有显示我的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40889522/

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