Breadcrumbs in Angular

后端 未结 1 1669
春和景丽
春和景丽 2021-02-15 17:43

I want to use Angular\'s breadcrumb capability. I added this javascript file to my services folder.

I added a div to my header.html file to call the javascript. Accordin

1条回答
  •  既然无缘
    2021-02-15 18:12

    It's not enough to just add the HTML to your header template file. Make sure you've also completed the following:

    1. Include breadcrumbs.js in your main HTML template (usually index.html):

      
      
    2. Include services.breadcrumbs as a module dependency for your main app:

      angular.module('myMainApp', ['services.breadcrumbs']);
      
    3. Finally, make sure you actually inject the breadcrumbs service into your controller, and then attach it to $scope:

      angular.module('myMainApp').controller('FooBarCtrl', function($scope, breadcrumbs) {
          $scope.breadcrumbs = breadcrumbs;
      
          // ... other controller logic ...
      });
      

    You can see the implementation of Steps 2 and 3 in the angular-app project in the app.js file (refer to lines 6, 60, and 62).

    0 讨论(0)
提交回复
热议问题