首先它需要一些时间来加载angularjs然后加载输出。我如何改进它?首次加载:
几秒钟后输出时间正确:
var app = angular.module('myApp', []).config(function ($interpolateProvider) {
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
{[{ firstName + " " + lastName }]}
</div>
&#13;
答案 0 :(得分:1)
您可以添加ng-cloak
以避免它。
var app = angular.module('myApp', []).config(function ($interpolateProvider) {
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl" ng-cloak>
{[{ firstName + " " + lastName }]}
</div>
答案 1 :(得分:1)
ng-cloak将为您完成这项工作,它不会让角度表达式在视图上打印,请阅读文档以获取更多详细信息:
https://docs.angularjs.org/api/ng/directive/ngCloak
你可以将它用于整个身体或元素,如:
<div ng-cloak> {{someExpression}} </div>