采用了棱角分明的NG-如果 [英] Using Angular's ng-if

查看:179
本文介绍了采用了棱角分明的NG-如果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看着精通Web应用程序开发的角度,我试着使用 NG-如果指令不显示< D​​IV> 如果前女友pression是

Looking at Mastering Web Application Development in Angular, I tried to use the ng-if Directive to not show a <div> if an expression was false.

HTML

<div ng-controller="MyCtrl">
    <div ng-if="showSecret">Secret</div>
</div>

的JavaScript

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

function MyCtrl($scope) {  
    $scope.showSecret = (function() { 
        return false;
    })();
}

不过,看着这的jsfiddle( http://jsfiddle.net/64GCp/2/ ),我看到揭秘获取呈现。为什么呢?

But, looking at this JsFiddle(http://jsfiddle.net/64GCp/2/), I see that Secret gets rendered. Why?

推荐答案

看起来你正在使用1.0.1版和文档的这里没有显示 ngIf 文件。

It looks like you are using v1.0.1 and documentation here doesn't show an ngIf document.

它的第一个实例我看到的是这里版本1.2.0

The first instance of it I see is here in version 1.2.0

更改库版本的作品: http://jsfiddle.net/64GCp/4/

这篇关于采用了棱角分明的NG-如果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆