gpt4 book ai didi

javascript - Angular js大括号在html中不显示值

转载 作者:太空狗 更新时间:2023-10-29 15:55:15 25 4
gpt4 key购买 nike

您好,我已经尝试了很多文章和不同问题的答案,但没有成功,我使用的是一个空白的 ionic 项目,它在我的浏览器上使用 ionic.serve 运行,也没有显示任何错误。

{{truck}} 显示在我的应用程序中,而不是值 "Truck Value"而且 {{truck}} 不会永久显示,它会在我刷新浏览器时立即闪烁。

html
<body ng-app="starter">
<div ng-controller="Ctrl">
<h2>hey {{truck}}</h2>
</div>
</body>

js

var example = angular.module('starter', ['ionic', 'ngCordova'])
...
example.controller("Ctrl", function() {

var truck = "Truck Value";

});

最佳答案

example.controller("Ctrl", function($scope) {

$scope.truck = "Truck Value";

});

关于javascript - Angular js大括号在html中不显示值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30727803/

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