【问题标题】:isolated scope data not displaying in directive template指令模板中未显示隔离范围数据
【发布时间】:2020-02-20 06:46:59
【问题描述】:

我正在构建一个自定义 Angular 指令来在我的应用程序中显示分页。

我正在使用隔离范围传递totalNoOfRecords,但它没有显示出来。任何帮助将不胜感激

这是我目前尝试过的代码

我调用指令的模板:

<pagination totalData="111"></pagination>

Directive.js

function pagination() {
    return {
        restrict: 'EA',
        templateUrl: 'template/directives/pagination.html',
        scope: {
            totalData: '@',
        },
        link: dirPaginationControlsLinkFn
    };
}

指令模板

<span class="pagination-text">
   of {{totalData}} 
</span>

【问题讨论】:

    标签: angularjs angularjs-directive isolated-scope


    【解决方案1】:

    在 AngularJS 中,作用域绑定在 JS 中应该是 camelCase,在 HTML 中应该是 kebab-case。

    你必须改变你的HTML

    <pagination totalData="111"></pagination>
    

    <pagination total-data="111"></pagination>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多