主頁 > 知識庫 > AngularJS tab欄實現(xiàn)和mvc小案例實例詳解

AngularJS tab欄實現(xiàn)和mvc小案例實例詳解

熱門標簽:上海企業(yè)外呼系統(tǒng)價錢 河間市地圖標注app 地圖標注推銷坑人 電銷機器人 長春 中國地圖標注不明確情況介紹表 大眾點評400電話怎么申請 東平縣地圖標注app 立陶宛地圖標注 怎樣在地圖標注文字

tab欄:

代碼:

!DOCTYPE html> 
html lang="en"> 
head> 
  meta charset="UTF-8"> 
  title>Tab 標簽/title> 
  style> 
    body { 
      margin: 0; 
      padding: 0; 
      background-color: #F7F7F7; 
    } 
    .tabs { 
      width: 400px; 
      margin: 30px auto; 
      background-color: #FFF; 
      border: 1px solid #C0DCC0; 
      box-sizing: border-box; 
    } 
    img { 
      width: 400px; 
    } 
    .tabs nav { 
      height: 40px; 
      text-align: center; 
      line-height: 40px; 
      overflow: hidden; 
      background-color: #C0DCC0; 
      display: flex; 
    } 
    nav a { 
      display: block; 
      width: 100px; 
      border-right: 1px solid #FFF; 
      color: #000; 
      text-decoration: none; 
    } 
    nav a:last-child { 
      border-right: 0 none; 
    } 
    nav a.active { 
      background-color: #9BAF9B; 
    } 
    .cont { 
      overflow: hidden; 
      /*display: none;*/ 
    } 
    .cont ol { 
      line-height: 30px; 
    } 
    p { 
      text-align: center; 
      height: 30px; 
      line-height: 30px; 
    } 
    li { 
      list-style: none; 
      height: 30px; 
      line-height: 30px; 
    } 
  /style> 
  !--[if lte IE 6]> 
  ![endif]--> 
/head> 
body ng-app="Tabs"> 
  div class="tabs" ng-controller="TabsController"> 
    nav> 
    !-- 指令之間沒有分號 --> 
      a href="javascript:;" ng-class="{active: type == 'local'}" ng-mouseover="switch('local')">白山茶/a> 
      a href="javascript:;" ng-class="{active: type == 'global'}" ng-mouseover="switch('global')">作曲/a> 
      a href="javascript:;" ng-class="{active: type == 'sports'}" ng-mouseover="switch('sports')">背景/a> 
      a href="javascript:;" ng-class="{active: type == 'funny'}" ng-mouseover="switch('funny')">歌詞/a> 
    /nav> 
    div ng-switch on="type"> 
      section class="cont" ng-switch-when="local"> 
        p>2017.5.24/p> 
      /section> 
      section class="cont" ng-switch-when="global"> 
        p>作曲:陳雪凝/p> 
        p>作詞:陳雪凝/p> 
        p>編曲:海藝音樂/p> 
      /section> 
      section class="cont" ng-switch-when="sports"> 
          img src="bsc.png"> 
      /section> 
      section class="cont" ng-switch-when="funny"> 
        ul> 
          li>你認真的說你喜歡白山茶/li> 
          li>怡然自得的收起別的紅玫瑰/li> 
          li>你溫柔的說你眷戀我/li> 
          li>然后迫不及待的愛別人/li> 
          li>然后迫不及待的愛別人/li> 
          li>然后迫不及待的愛別人/li> 
          li>然后迫不及待的愛別人/li> 
        /ol> 
      /section> 
    /div> 
  /div> 
  script src="../../js/angular.min.js">/script> 
  script> 
    angular.module('Tabs',[]).controller('TabsController',['$scope',function($scope){ 
       $scope.type = 'local'; 
       $scope.switch = function(type){ 
        $scope.type = type; 
       } 
    }]); 
  /script> 
/body> 
/html> 

mvc小案例:

代碼:

!doctype html> 
html lang="en"> 
  head> 
    meta charset="utf-8"> 
    meta name="viewport" content="width=device-width, initial-scale=1"> 
    title>Template • TodoMVC/title> 
    !-- link rel="stylesheet" href="css/base.css"> --> 
    link rel="stylesheet" href="css/index.css"> 
    !-- CSS overrides - remove if you don't need it --> 
    link rel="stylesheet" href="css/app.css"> 
  /head> 
  body ng-app="Todos"> 
    section class="todoapp" ng-controller="TodoController"> 
      header class="header"> 
        h1>todos/h1> 
        form ng-submit="add()"> 
        !-- 用戶輸入點 --> 
          input class="new-todo" placeholder="What needs to be done?" ng-model="text" autofocus> 
        /form> 
      /header> 
      section class="main"> 
        input class="toggle-all" type="checkbox"> 
        label for="toggle-all">Mark all as complete/label> 
        ul class="todo-list"> 
          li ng-repeat="(key,todo) in todos"> 
            div class="view"> 
              input type="checkbox" class="toggle" ng-click="done(key)" > 
              label>{{todo.text}}/label> 
              button class="destroy" ng-click="delete(todos,key)" >/button> 
            /div> 
            input class="edit" value="Create a TodoMVC template"> 
          /li> 
          li>h5>已完成/h5>/li> 
          li class="completed" ng-repeat="todo in doneTodos"> 
            div class="view"> 
              input class="toggle" type="checkbox" ng-checked="todo.flag" > 
              label>{{todo.text}}/label> 
              button class="destroy" ng-click="delete(doneTodos,key)">/button> 
            /div> 
            input class="edit" value="Rule the web"> 
          /li> 
        /ul> 
      /section> 
      footer class="footer"> 
        span class="todo-count">strong>/strong> {{todos.length}} item left/span> 
        button class="clear-completed">Clear completed/button> 
      /footer> 
    /section> 
    footer class="info"> 
      p>Double-click to edit a todo/p> 
      p>Template by a >Sindre Sorhus/a>/p> 
      p>Created by a >you/a>/p> 
      p>Part of a >TodoMVC/a>/p> 
    /footer> 
  /body> 
  script src="../../js/angular.min.js">/script> 
  script> 
    angular.module('Todos',[]).controller('TodoController',['$scope',function($scope){ 
      // 定義一個數(shù)組存儲用戶輸入的數(shù)據(jù) 
      $scope.todos = []; 
      $scope.doneTodos = []; 
      $scope.add = function(){ 
        $scope.todos.push({text:$scope.text,flag:false}); 
        $scope.text = ''; 
      } 
      $scope.done = function(key){ 
      var todo = $scope.todos.splice(key,1)[0]; 
      todo.flag = true; 
      $scope.doneTodos.push(todo); 
      // console.log($scope.todos.splice(key,1)); 
      } 
      $scope.delete = function(todos,key){ 
        todos.splice(key,1); 
      } 
    }]); 
  /script> 
/html> 

以上所述是小編給大家介紹的AngularJS tab欄實現(xiàn)和mvc小案例實例詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

您可能感興趣的文章:
  • bootstrap-table.js擴展分頁工具欄(增加跳轉到xx頁)功能
  • 使用ReactJS實現(xiàn)tab頁切換、菜單欄切換、手風琴切換和進度條效果
  • Extjs 3.3切換tab隱藏相應工具欄出現(xiàn)空白解決
  • JS實現(xiàn)table表格固定表頭且表頭隨橫向滾動而滾動
  • js實現(xiàn)Tab選項卡切換效果
  • JS 組件系列之Bootstrap Table的凍結列功能徹底解決高度問題
  • 使用vue.js寫一個tab選項卡效果
  • js tab欄切換代碼實例解析

標簽:銅川 本溪 玉樹 營口 四川 內(nèi)江 益陽 遼寧

巨人網(wǎng)絡通訊聲明:本文標題《AngularJS tab欄實現(xiàn)和mvc小案例實例詳解》,本文關鍵詞  AngularJS,tab,欄,實現(xiàn),和,mvc,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《AngularJS tab欄實現(xiàn)和mvc小案例實例詳解》相關的同類信息!
  • 本頁收集關于AngularJS tab欄實現(xiàn)和mvc小案例實例詳解的相關信息資訊供網(wǎng)民參考!
  • 推薦文章