AngularJS,显示布尔值的文本

时间:2014-11-06 19:18:59

标签: angularjs

Is Boss? : true具有布尔person.IsBoss时,我有以下带有AJS的HTML,我希望看到true

<span>Is Boss? :</span> <span> {{ person.IsBoss }}</span>

但它会显示为

Is Boss? :

如何制作AJS显示&#34; true&#34;或&#34;假&#34;对于布尔值?

1 个答案:

答案 0 :(得分:1)

您的代码应该可以正常工作,看看:

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

function MyCtrl($scope) {
  $scope.person = {
    isBoss: true
  };
}
<body ng-app>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

  <div ng-controller="MyCtrl">
    <span>Is Boss? :</span>  <span> {{ person.isBoss }}</span>

  </div>
</body>