NG-视图内嵌套指令不起作用AngularJs [英] Nested directive within ng-view doesn't work AngularJs

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

问题描述

我开发利用的角度NG-鉴于原生指令来改变视图的SPA,问题是其中的一个观点有我写了一个自定义的指令,在道路被加载指令不起作用。

这是一个不火起来的应用程序和自定义指令的配置方法:•

  climbingApp.config(
        功能($ routeProvider){
            $ routeProvider。            什么时候('/', {
                控制器:'AppCtrl
            })。            当('/ newSector',{
                模板:'< formNewSector>< / formNewSector>,
                控制器:'addSector',
            })。            否则({redirectTo:'/'});
        }
    );
climbingApp.directives        。指示(
            formNewSector',
            功能(){                返回{
                    限制:'E',
                    模板:< D​​IV>&加托LT; / DIV>中,
                    更换:真实,
                    链接:功能(范围,iElement,iAttrs){                    }
                }
    });


解决方案

您在您的模板指令拼写错误的标记。对于命名指令 formNewSector 应该是<形式新部门> ,而不是&LT ; formNewSector方式>

I developing a SPA using the native directive from angular ng-view to change views, the problem is that One of those views there is a custom directive I've wrote and when the route is loaded the directive doesnt work.

Here it is the config method of the App and the custom directive that doesn't fire up :S

climbingApp.config(
        function( $routeProvider ){
            $routeProvider.

            when('/', {
                controller: 'AppCtrl'
            }).

            when('/newSector', {
                template: '<formNewSector></formNewSector>',
                controller: 'addSector',
            }).

            otherwise({ redirectTo: '/'});
        }
    );


climbingApp.directives

        .directive(
            'formNewSector',
            function() {

                return {
                    restrict: 'E',
                    template: "<div>gato</div>",
                    replace: true,
                    link: function( scope, iElement, iAttrs ){

                    }
                }
    });

解决方案

You misspelled markup for directive in your template. For directive named formNewSector it should be <form-new-sector>, not <formNewSector>.

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

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