1. Implement the tag page through ordinary instructions
<link rel="stylesheet" href="views/show/tab.css"/><div> <ul ng-init="vm.activeTab=1"> <li ng-class="{active: vm.activeTab == 1}"><a href="javascript:;" ng-click="vm.activeTab = 1">Tag1</a></li> <li ng-class="{active: vm.activeTab == 2}"><a href="javascript:;" ng-click="vm.activeTab = 2">Tag2</a></li> </ul> <div> <div ng-show="vm.activeTab = 2}"><a href="javascript:;" ng-click="vm.activeTab = 2">Tag2</a></li> </ul> <div> <div ng-show="vm.activeTab = 2}"><a href="javascript:;" ng-click="vm.activeTab = 2">Tag2</a></li> </ul> <div> <div ng-show="vm.activeTab == 1"> Content of tag 1</div> <div ng-show="vm.activeTab == 2"> Content of tag 2</div> </div></div><h3> Description</h3> Here is a method that is directly implemented through bootstrap. <hr/>It can also be implemented through the tabset directive of angular-bootstrap, see <a href="http://angular-ui.github.io/bootstrap/#/tabs" target="_blank">Official Demo</a>'use strict';angular.module('ngShowcaseApp').controller('ctrl.show.tab', function ($scope) { var vm = $scope.vm = {};});.tab-content.tab-bordered { border: 1px solid lightgray; border-top: none; padding: 15px; border-radius: 0 0 4px 4px;}2. Customized command implementation tag page
<!DOCTYPE html><html lang="en" ng-app="demo"><head> <meta charset="UTF-8"> <title></title> <script src="lib/angular.min.js" type="text/javascript"></script> <script src="lib/angular-route.js" type="text/javascript"></script> <script src="lib/jquery-2.1.4.min.js"></script> <link rel="stylesheet" href="css/bootstrap.css" type="text/css"/> <style> .btn-group{ position: relative; left: 40px; } .list-group{ position: relative; left: 0; } .list-group-item{ } #list3{ width: 200px; } </style></head><body > <div ng-controller="directiveControl"> <div ng-class="{'hidden':value}" ></div> <div> <list ng-model="value" ></list> </div> <script type="text/ng-template" id="list.html"> <div > <ul> <li role="presentation" ng-mouseover="flag=3" ng-mouseleave="flag=4"><a href="#" >{{name}}</a></li> </ul> </div> <div id="list3" ng-show="flag==3" ng-mouseover="flag=3" ng-mouseleave="flag=4"> <ul > <li ng-click="fun1()"><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li><a href="#">Separated link</a></li> </ul> </div> </script> </div> </script> </div></body><script> var demo=angular.module("demo",[]); demo.controller("directiveControl", function ($scope) { }); demo.directive("list",[function () { return { restrict:'EA', templateUrl:'list.html', scope:{ value:'=ngModel' }, link: function (scope,element,attr) { scope.name="home"; scope.lists=[{name:'home'},{name:'family '}]; scope.fun1= function () { scope.value=true; console.log("a") } } } } }])</script></html>(1) First of all, we must solve the problem that the instructions must be written in a root tag, and must be wrapped in a div
(2) Use ng-model to declare variables when passing parameters outside the instruction.
Use scope in directive: {
value:'ngModel'
} to assign value
Summarize
The above is all about the AngularJS implementation tab. I hope this article will be helpful to everyone to learn or use AngularJs. If you have any questions, you can leave a message to communicate.