创建新的范围示例

create new scope exemplar

本文关键字:范围 创建      更新时间:2023-11-06

我有一个选项卡应用程序。我使用templateUrl:从指令中通过的选项卡内容

return {
       restrict : 'E',
       templateUrl : 'tab-content.html'
}

我可以更改此内容-添加新学生。但当我按下一个新的选项卡时,显示的内容发生了变化。如何使用初始内容创建新选项卡?

以下是

的示例

您的指令需要自己的作用域:

return {
   scope: {
      studends: '@',
      grades: '@'
   },
   restrict : 'E',
   templateUrl : 'tab-content.html'
}

也许也可以考虑在指令中添加一个链接函数。

https://docs.angularjs.org/guide/directive