内ngView嵌套指令不起作用角JS [英] Nested directive within ngView does not work Angular JS

查看:156
本文介绍了内ngView嵌套指令不起作用角JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有确切的问题,因为这<一个href=\"http://stackoverflow.com/questions/19390425/nested-directive-within-ng-view-doesnt-work-angularjs\">stackoverflow问题。嵌套指令不ngview和routeconfig工作。但我的问题是不相关的语法。

I'm having exact problem as this stackoverflow question. Nested directive does not work with ngview and routeconfig. But my problem is not related to syntax.

我已经定义的模块如下:

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

配置code:

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 code

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

从开发工具中查看时的 HTML code

<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>

问题:
我看不出在控制台中的任何错误,但&LT;喜的仪表板&GT; 内容这是仪表盘的指令不是在浏览器中显示。任何帮助将是AP preciated。

Problem: I do not see any errors in console but <hi-dashboard> content 'This is dashboard directive' is not displayed in the browser. Any help would be appreciated.

推荐答案

模板是在你的指令拼写错误:

Template is spelled incorrectly in your directive:

tempalte:这是仪表盘的指令

模板:这是仪表盘的指令

这篇关于内ngView嵌套指令不起作用角JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆