百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>JS教程> AngularJS如何打开页面隐藏显示表达式的教程
分享文章到:

AngularJS如何打开页面隐藏显示表达式的教程

发布时间:01/15 来源: 浏览: 关键词:
这篇文章介绍了AngularJS如何打开页面隐藏显示表达式的教程,简单易懂还附上了实例代码,有需要的同学快看看吧!

本文实例讲述了AngularJS打开页面隐藏显示表达式用法。分享给大家供大家参考,具体如下:

1.使用 ng-cloak, 同时要在css加入一行 [ng-cloak] {display: none;} 样式 [ng:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }

2.使用ng-bind, 代替{{}} 这个不太方便,因为使用ng-bind后必须要一个DOM节点绑定, 例如span上, 没有直接{{}} 用不需要DOM节点方便

3.使用ng-model

<% include common/header.html %>

  <style>[ng-cloak] {display: none !important;}</style>

  <!-- S main -->

  <div class="main g_cf"ng-app="myApp">

    <div class="contain_lf">

      <h2 class="about_tit">ABOUT</h2>

      <div class="ab_content"ng-controller="aboutus"ng-show="true">

        <div class="hr"ng-bind="clumnData.title"ng-cloak></div>

        <p ng-bind="clumnData.detail"></p>

        <p ng-cloak>{{clumnData.email.title}}:<a href="mailto:{{clumnData.email.link}}"target="_blank"ng-bind="clumnData.email.link"ng-cloak>768065158@qq.com</a></p>

        <p ng-repeat ="item in clumnData.list"ng-cloak >{{item.title}}:<a href="{{item.link}}"target="_blank"ng-bind="item.link"ng-cloak></a></p>

      </div>

      <div class="ab_content"ng-controller="comment">

        <div class="hr"ng-bind="title"ng-cloak></div>

        <div class="comment_user">

          <input type="text"name="username"placeholder="您的大名">

        </div>

        <div class="comment_con">

          <textarea id="editArea"maxlength="300"placeholder="请输入评论,少于300字符"></textarea>

          <div class="comment_btn">

            <span>ctrl + enter 发送评论,字数:0/300</span><input type="submit"class="commit_btn"value="确认"ng-click ="comment()">

          </div>

        </div>

      </div>

      <input type="text"ng-model="name">{{name}}

    </div>

    <div class="contain_rg">

      <div class="rg_tp_clum1">

        <h2>欢迎来到pfan空间</h2>

        <p>这里有更多的知识分享,交流。</p>

        <p><%= content %></p>

        <p><%= date %></p>

      </div>

    </div>

  </div>

  <div id="next">111111</div>

  <!-- E main -->

<% include common/Jsfoot.html %>

<script>

angular.element(document.getElementById("next")).bind('click',function() {

    alert(this.innerHTML);

  });

  varapp = angular.module("myApp",[],function(){console.log('strat')});

  varclumnData = {

    title:"关于我",

    detail:"小前端一枚,喜欢javascript、喜欢nodejs、喜欢canvas",

    email:{title:"邮箱",link:"768065158@qq.com"},

    list:[{title:"github",link:"https://github.com/pingfanren/"},

      {title:"一聚教程网",link:"http://www.111cn.net/"},

      {title:"技术分享平台",link:"http://pingfan1990.sinaapp.com/"},

      {title:"前端导航平台",link:"http://doc.pfan123.com/"},

    ]

  };

   app.controller("aboutus",function($scope){

     $scope.clumnData = clumnData;

   });

   app.controller("comment",function($scope){

     $scope.title ="给我留言";

     $scope.comment=function(){

    }

   });

</script>

<% include common/footer.html %>

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有2人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板