Вложенная директива в ngView не работает Angular JS

0

У меня есть точная проблема, как этот qaru.site/questions/7472778/.... Вложенная директива не работает с ngview и routeconfig. Но моя проблема не связана с синтаксисом.

Я определил модули, как показано ниже:

angular.module('hiDashboard', []);
angular.module('hiFramework', ['hiDashboard']);
angular.module('app', ['hiFramework']);

Код конфигурации:

angular.module('app').config(function ($routeProvider) {
  var routes = [
    {
      url: '/dashboard',
      config: { template: '<wwa-dashboard></wwa-dashboard>' }
    },
    {
      url: '/friends',
      config: { template: '<wwa-friends></wwa-friends>' }
    },
    {
      url: '/favouriteList',
      config: { template: '<wwa-favourite-list></wwa-favourite-list>' }
    }
  ];
  routes.forEach(function (route) {
    $routeProvider.when(route.url, route.config);
  });

   $routeProvider.otherwise({redirectTo: '/dashboard'});

});

Директива wwaDashboard

"use strict";
angular.module('app').directive('wwaDashboard', function () {
  return {
    restrict: 'AE',
    scope: {},
    template: '<hi-dashboard></hi-dashboard>',
    link: function (scope) {

    }
  };
});

Директива hiDashboard

"use strict";
angular.module('hiDashboard').directive('hiDashboard', function () {
  return {
    restrict: 'AE',
    tempalte: 'This is dashboard directive'
  };
});

Фактический код HTML

<div ng-view class="hi-dashboard-view"></div>

HTML-код при просмотре с помощью инструментов разработчика

<div ng-view class="hi-dashboard-view ng-scope">
 <wwa-dashboard class="ng-scope ng-isolate-scope">
  <hi-dashboard></hi-dashboard>
</wwa-dashboard>
</div>

Ожидаемый HTML:

<div ng-view class="hi-dashboard-view ng-scope">
 <wwa-dashboard class="ng-scope ng-isolate-scope">
  <hi-dashboard>This is dashboard directive</hi-dashboard>
</wwa-dashboard>
</div>

Проблема: я не вижу никаких ошибок в консоли, но <hi-dashboard> content 'This is dashboard directive' не отображается в браузере. Любая помощь будет оценена по достоинству.

Теги:
angularjs-directive
route-provider

1 ответ

0
Лучший ответ

Шаблон неправильно указан в вашей директиве:

tempalte: 'This is dashboard directive'

должно быть

template: 'This is dashboard directive'

Ещё вопросы

Сообщество Overcoder
Наверх
Меню