Home > Web Front-end > JS Tutorial > AngularJS develops WebApp to achieve highlight jump button effect, how to use ui-sref and ui-sref-active

AngularJS develops WebApp to achieve highlight jump button effect, how to use ui-sref and ui-sref-active

一个新手
Release: 2017-09-23 09:39:06
Original
2027 people have browsed it

AngularJS develops WebApp to achieve highlight jump button effect, how to use ui-sref and ui-sref-active

The highlighting effect of the menu bar at the bottom of WebApp needs to use a command. In fact, it also needs to do an interaction, that is, it needs to jump when clicked. In this case, ui is generally used. .router is an instruction of the routing module. There are generally two ways to jump. One is to use instructions to jump, and the other is to use services to jump.

The instruction is ui-sref, which is equivalent to binding a click event to this element. When this element is clicked, it will jump to the corresponding page or route.

When clicked at the same time, the button also needs to have a highlighting effect. This command is called ui-sref-active=”select”

html

<ul class="bg-w foot">
  <li ui-sref-active="select" ui-sref="main"><span>首页</span></li>
  //这个意思是说如果当前点击的路由是main的话,首先点击这个路由会跳转到main的页面,
  //然后如果当前页面就是它的话,那么就会包含select这个样式类的名称  <li ui-sref-active="select" ui-sref="search"><span>附近</span></li>
  <li ui-sref-active="select" ui-sref="me"><span>我</span></li></ul>
Copy after login

routing

&#39;use strict&#39;;
angular.module(&#39;app&#39;).config([&#39;$stateProvider&#39;, &#39;$urlRouterProvider&#39;, function($stateProvider, $urlRouterProvider) {
  $stateProvider.state(&#39;main&#39;, {
    url: &#39;/main&#39;,
    templateUrl: &#39;view/main.html&#39;,
    controller: &#39;mainCtrl&#39;
  });
  $urlRouterProvider.otherwise(&#39;main&#39;);
}])
Copy after login

.Less file

@highlightBgColor: #dbf9f4;@highlightColor: #01c2a3;

  li {    font-size: 20px;
    width: 33.33%;
    color: @muteColor;
    &.select {      background-color: @highlightBgColor;
      color: @highlightColor;
    }
  }
Copy after login

The above is the detailed content of AngularJS develops WebApp to achieve highlight jump button effect, how to use ui-sref and ui-sref-active. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template