javascript - Angular Ionic - 指令在 View 更改时不重新加载

标签 javascript angularjs ionic-framework

由于 ionic 具有 View 缓存,因此如何在 View 加载时重新加载特定指令。我不想使用 cache: false 并重新加载整个 View 。我在指令定义对象的 Controller 函数中尝试了以下操作。

.controller('MyCtrl', function($scope) {
  $scope.$on("$ionicView.enter", function () {
     // logic
  });
})

但是由于 ionic View 缓存,指令本身的 Controller 功能没有加载。

如何在 ionic 中制定在 View 更改时重新加载的指令。

最佳答案

在您的指令中,使用 ionic View 中的数据,并在 $ionicview.enter 函数中重新加载指令显示的数据。

例如

restrict: 'E',
scope: true,
bindToController: true,
controller: function ($scope, $element) { ... }

关于javascript - Angular Ionic - 指令在 View 更改时不重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37723109/

相关文章:

javascript - 在平滑传输和颜色变化中调整拨动开关

javascript - 如何将对象传递给 AngularJS 控制对象到 MVC 5 中的另一个 AngularJS Controller

angularjs - 从 $routeProvider 以 Angular 获取路线列表

ios - 找不到模块 'simple-plist'

ios - Ionic Cordova 自定义初始屏幕,带有适用于 IOS 的动态文本

javascript - 在 Javascript 中创建按键事件

javascript - 选择页面加载选项

javascript - 如何根据选择使新字段出现在表单中

javascript - ng-show ="frm.Email.$error.email "不显示无效电子邮件的错误

css - ionic 4 如何将 ionic 范围引脚放置在范围底部