您好,欢迎访问一九零五行业门户网

AngularJS之ng-if指令

1、问题背景
angularjs利用ng-if指令来判断对象元素是否为空
2、实现源码
<!doctype html> <html ng-app="ifapp"> <head> <meta charset="utf-8"> <title>angularjs之ng-if指令</title> <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> <script> var app = angular.module("ifapp",[]); app.controller("ifcontroller",function($scope){ $scope.person = { name:{ username:"张三", sex:"男", age:"23" }, scores:{ item:"语文",score:"123" } }; }); </script> </head> <body ng-controller="ifcontroller"> <p ng-if="person != null"> <p ng-repeat="p in person"> <p ng-if="person.name != null"> <label>{{p.username}}</label> </p> </p> </p> </body> </html>
3、实现结果
以上就是angularjs之ng-if指令的内容。
其它类似信息

推荐信息