angular templateURL的指令参数问题

时间:2016-10-27 10:42:04

标签: angularjs

我有以下指令

App.directive('minuteListDirective', function () {
    return {
        restrict: "A,E",
        required: 'ng-model',

        templateUrl: "/app/profile/company-minutes/templates/minute-list.html",
        controller: "CompanyMinutesController",
        replace: true,
        scope: {
            mode: '@mode',
        },
        link: function (scope, el, attrs) {

        },
    }
});

当我删除范围时:{                 模式:'@模式',             }, 从指令,模板正确呈现如下(minute-list.html)

<div dropdown="dropdown" class="btn-group btn-group-sm">
    <button dropdown-toggle="" ng-class="'btn btn-default'" class="ng-binding btn btn-default" aria-haspopup="true" aria-expanded="false">
        <b class="caret"></b> 
    </button>
    <ul role="menu" ng-class="'dropdown-menu animated flipInX'" class="dropdown-menu animated flipInX">
        <li>
            <a href="#" ng-click="update(minute)">edit</a>
        </li>
        <li class="hide-edit-mode">
            <a href="#" ng-click="delete(minute)">delete</a>
        </li>
    </ul>
</div>

但是当我添加范围:{mode:'@ mode'}来指示模板渲染但它从渲染模板中删除ng-class

<div dropdown="dropdown" class="btn-group btn-group-sm">
    <button dropdown-toggle="" ng-class="''" class="ng-binding" aria-haspopup="true" aria-expanded="false">
        <b class="caret"></b>operation
    </button>
    <ul role="menu" ng-class="''">
        <li>
            <a href="#" ng-click="update(minute)">edit</a>
        </li>
        <li class="hide-edit-mode">
            <a href="#" ng-click="delete(minute)">delete</a>
        </li>
    </ul>
</div>

这里是没有渲染的原始模板

<div dropdown="dropdown" class="btn-group btn-group-sm">
    <button dropdown-toggle="" ng-class="'btn btn-default'" class="ng-binding btn btn-default">
        <b class="caret"></b> {{resources.grid.ACTION_BUTTOM_TEXT}}
    </button>
    <ul role="menu" ng-class="'dropdown-menu animated flipInX'" class="dropdown-menu animated flipInX">
        <li>
            <a href="#" ng-click="update(minute)">edit</a>
        </li>
        <li class="hide-edit-mode">
            <a href="#" ng-click="delete(minute)">delete</a>
        </li>
    </ul>
</div>

0 个答案:

没有答案