Reuse AngularJS Component in another Module (Dependency Injection)
问题 how can I reuse a simple angular component via Dependency injection? Component: angular.module("navbar", []).component("nav", function() { console.log("component loaded"); }); Other Module Controller I want to use it in: angular.module('CtrlHome', ['navbar']).controller('HomeController', function($rootScope, $scope) { }); And finally use it in the template <nav></nav> It throws me a "injector modulerr" error. What am I doing wrong here? 回答1: The component isn't defined correctly. The