角度:多重指令要求的模板 [英] angular: multiple directives asking for templates on

查看:102
本文介绍了角度:多重指令要求的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有以下HTML:

            <div style="border:1px solid; height:300px; width:500px; position:relative;  left:100px" id="canvas">
                <tbox ng-repeat="tb in textBoxes" ng-model="tb">
                </tbox>
            </div>

和下列2指令

    appModule.directive('resizable', function($compile, $document) {
        return {
            restrict: "A",
            template: '<div ng-style="{top:tb.x, left:tb.y, height:tb.height, width:tb.width}"  ng-transclude><span class="scale">s</span></div>',
            transclude: true,
            replace: true,
            require: 'ngModel',


appModule.directive('tbox', function($document) {
    return {
        restrict: "E",
        template: '<div class="editbox" resizable editoptions>{{tb.text}}</div>',
        replace: true,

究竟做以下错误角度抛出我的意思吗?

What exactly does the following error that angular is throwing me means?

Error: Multiple directives [tbox, resizable] asking for template on: <div class="editbox" resizable="" editoptions="" ng-repeat="tb in textBoxes" ng-model="tb">

http://jsfiddle.net/sEZM3/

推荐答案

你的两个指令试图取代的DOM元素。请尝试删除的更换:真正的线在你的指令定义对象

Both of your directives are trying to replace the element in the dom. Try removing the the replace: true lines in your directive definition object.

这篇关于角度:多重指令要求的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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