AngularJS怎么自定义指令实现面包屑功能

这篇文章主要介绍了AngularJS怎么自定义指令实现面包屑功能,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

10年积累的成都网站建设、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有汝南免费网站建设让你可以放心的选择与我们合作。

具体如下:



 
  
  
  
  
  
  
  
  
   var myApp = angular.module('myApp', []);
   myApp.controller('Ctrl', function($scope){
    $scope.crumbOptions = [
     {"href": "http://www.baidu.com", "title" : "Home"},
     {"href": "http://www.sina.com", "title" : "Library"},
     {"href": "", "title" : "Data"}
    ];
   });
   myApp.directive("custBreadcrumb", function() {
    return {
     restrict: 'E',
     replace: true,
     scope: {
      options:'@'
     },
     link: function(scope, elem, attrs) {
      var parentNode = elem.parent();
      var crumbString = '';
      angular.forEach(scope.$eval(scope.options), function(item) {
       if (item["href"] != "") {
        var tempString = '
  • ' + item["title"] + '
  • ';          crumbString += tempString;        } else {         var tempString = '' + item["title"] + '';          crumbString += tempString;        }       });       crumbString += "";       parentNode.append(crumbString);      }     };    });            

    感谢你能够认真阅读完这篇文章,希望小编分享的“AngularJS怎么自定义指令实现面包屑功能”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


    分享名称:AngularJS怎么自定义指令实现面包屑功能
    URL链接:http://lszwz.com/article/psocpe.html

    其他资讯

    售后响应及时

    7×24小时客服热线

    数据备份

    更安全、更高效、更稳定

    价格公道精准

    项目经理精准报价不弄虚作假

    合作无风险

    重合同讲信誉,无效全额退款