在我的文中我有代码:
<div>{{ user.userName }}</div>
如果user.userName为null,我有没有办法让这个显示消息“请登录”.注意我想在客户端而不是控制器中编写此业务逻辑.
<div>{{ user.userName || 'alternate text' }}</div>
<br>
<html>
<head>
<script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js">
</script>
<link rel="stylesheet" href="style.css" />
</head>
<body ng-controller="test">
<span>{{user.name || "alt text"}}</span>
<script>
var app = angular.module("app",[]);
app.controller("test",function($scope) {});
angular.bootstrap(document,["app"]);
</script>
</body>
</html>