當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript IRootScopeService.%24on方法代碼示例

本文整理匯總了TypeScript中angular.IRootScopeService.%24on方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IRootScopeService.%24on方法的具體用法?TypeScript IRootScopeService.%24on怎麽用?TypeScript IRootScopeService.%24on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular.IRootScopeService的用法示例。


在下文中一共展示了IRootScopeService.%24on方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: catch

  internals.$setupBreadcrumbsAutoClear = ($rootScope: IRootScopeService, $injector: any) => {
    const uiSettings = chrome.getUiSettingsClient();
    const $route = $injector.has('$route') ? $injector.get('$route') : {};

    $rootScope.$on('$routeChangeStart', () => {
      breadcrumbSetSinceRouteChange = false;
    });

    $rootScope.$on('$routeChangeSuccess', () => {
      const current = $route.current || {};

      if (breadcrumbSetSinceRouteChange || (current.$$route && current.$$route.redirectTo)) {
        return;
      }

      const k7BreadcrumbsProvider = current.k7Breadcrumbs;
      if (!k7BreadcrumbsProvider || !uiSettings.get('k7design')) {
        newPlatformChrome.setBreadcrumbs([]);
        return;
      }

      try {
        chrome.breadcrumbs.set($injector.invoke(k7BreadcrumbsProvider));
      } catch (error) {
        fatalError(error);
      }
    });
  };
開發者ID:gingerwizard,項目名稱:kibana,代碼行數:28,代碼來源:breadcrumbs.ts

示例2: init

  init() {
    this.$rootScope.$on('$routeUpdate', (evt, data) => {
      const angularUrl = this.$location.url();
      const state = store.getState();
      if (state.location.url !== angularUrl) {
        store.dispatch(
          updateLocation({
            path: this.$location.path(),
            query: this.$location.search(),
            routeParams: this.$route.current.params,
          })
        );
      }
    });

    this.$rootScope.$on('$routeChangeSuccess', (evt, data) => {
      store.dispatch(
        updateLocation({
          path: this.$location.path(),
          query: this.$location.search(),
          routeParams: this.$route.current.params,
        })
      );
    });

    // Listen for changes in redux location -> update angular location
    store.subscribe(() => {
      const state = store.getState();
      const angularUrl = this.$location.url();
      const url = locationUtil.stripBaseFromUrl(state.location.url);
      if (angularUrl !== url) {
        this.$timeout(() => {
          this.$location.url(url);
          // some state changes should not trigger new browser history
          if (state.location.replace) {
            this.$location.replace();
          }
        });
        console.log('store updating angular $location.url', url);
      }
    });

    appEvents.on('location-change', (payload: any) => {
      const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href);
      if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
        this.$window.location.href = payload.href;
        return;
      }

      this.$timeout(() => {
        // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
        this.$location.url(urlWithoutBase);
      });
    });
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:55,代碼來源:bridge_srv.ts

示例3:

    $setupHelpExtensionAutoClear: ($rootScope: IRootScopeService, $injector: any) => {
      const $route = $injector.has('$route') ? $injector.get('$route') : {};

      $rootScope.$on('$routeChangeStart', () => {
        helpExtensionSetSinceRouteChange = false;
      });

      $rootScope.$on('$routeChangeSuccess', () => {
        const current = $route.current || {};

        if (helpExtensionSetSinceRouteChange || (current.$$route && current.$$route.redirectTo)) {
          return;
        }

        newPlatformChrome.setHelpExtension(current.helpExtension);
      });
    },
開發者ID:lucabelluccini,項目名稱:kibana,代碼行數:17,代碼來源:help_extension.ts

示例4: run

export function run(
    $log: ILogService,
    $rootScope: IRootScopeService,
    $timeout: ITimeoutService
) {
    $log.debug('app module - run');

    $rootScope.$on('$stateChangeStart',
        function (event: ng.IAngularEvent, toState) {
            $log.debug('$stateChangeStart - name:', toState.name);
        });

    $rootScope.$on('$stateChangeSuccess',
        function (event, toState) {
            $log.debug('$stateChangeSuccess - name:', toState.name);
        });

    $rootScope.$on('$stateNotFound',
        function (event, unfoundState, fromState, fromParams) {
            $log.warn('$stateNotFound', {
                event: event,
                unfoundState: unfoundState,
                fromState: fromState,
                fromParams: fromParams
            });
        });

    $rootScope.$on('$stateChangeError',
        function (event, toState, toParams, fromState, fromParams, error) {
            $log.error('$stateChangeError', {
                event: event,
                toState: toState,
                toParams: toParams,
                fromState: fromState,
                fromParams: fromParams,
                error: error
            });
            if (error) {
                throw error;
            }
        });
};
開發者ID:egilsster,項目名稱:ionic-webpack-typescript,代碼行數:42,代碼來源:index.run.ts

示例5: bindEvents

  private bindEvents(): void {
    // WHY??? Because, when the stateChangeStart event fires, the $location.search() will return whatever the query
    // params are on the route we are going to, so if the user is using the back button, for example, to go to the
    // Infrastructure page with a search already entered, we'll pick up whatever search was entered there, and if we
    // come back to this application, we'll get whatever that search was.
    this.$rootScope.$on('$locationChangeStart', (_event: IAngularEvent, toUrl: string, fromUrl: string) => {
      const [oldBase, oldQuery] = fromUrl.split('?'),
        [newBase, newQuery] = toUrl.split('?');

      if (oldBase === newBase) {
        this.mostRecentParams = newQuery ? UrlParser.parseQueryString(newQuery) : {};
      } else {
        this.mostRecentParams = oldQuery ? UrlParser.parseQueryString(oldQuery) : {};
      }
    });

    this.$rootScope.$on('$stateChangeStart', (_event: IAngularEvent, toState: Ng1StateDeclaration, _toParams: StateParams, fromState: Ng1StateDeclaration, fromParams: StateParams) => {
      if (this.movingFromSecurityGroupState(toState, fromState)) {
        this.asFilterModel.saveState(fromState, fromParams, this.mostRecentParams);
      }
    });

    this.$rootScope.$on('$stateChangeSuccess', (_event: IAngularEvent, toState: Ng1StateDeclaration, toParams: StateParams, fromState: Ng1StateDeclaration) => {
      if (this.isSecurityGroupStateOrChild(toState.name) && this.isSecurityGroupStateOrChild(fromState.name)) {
        this.asFilterModel.applyParamsToUrl();
        return;
      }
      if (this.movingToSecurityGroupState(toState)) {
        if (this.shouldRouteToSavedState(toParams, fromState)) {
          this.asFilterModel.restoreState(toParams);
        }

        if (this.fromSecurityGroupsState(fromState) && !this.asFilterModel.hasSavedState(toParams)) {
          this.asFilterModel.clearFilters();
        }
      }
    });
  }
開發者ID:robfletcher,項目名稱:deck,代碼行數:38,代碼來源:securityGroupFilter.model.ts

示例6: watchFn

 scope.$on( '$destroy', () => {
     $rootScope.$on( '$ionicView.beforeLeave', () => modal.hide() );
     modal.remove();
     watchFn();
 });
開發者ID:prodest,項目名稱:es-na-palma-da-mao-mobile,代碼行數:5,代碼來源:modal.component.ts

示例7: ItemReviewController

function ItemReviewController(
  this: IController & {
    item: DimItem;
    toUserReview(item: DimItem): WorkingD1Rating | WorkingD2Rating;
    findReview(reviewId: string): D1ItemUserReview | D2ItemUserReview | null;
    getReviewData(): number[];
  },
  $rootScope: IRootScopeService
) {
  'ngInject';

  const vm = this;
  vm.canReview = settings.allowIdPostToDtr;
  vm.allowIdPostToDtr = settings.allowIdPostToDtr;
  vm.showReviews = settings.showReviews;
  vm.toggledFlags = [];
  vm.submitted = false;
  vm.isCollapsed = false;
  vm.expandReview = false;

  vm.$onInit = () => {
    vm.canCreateReview = vm.canReview && vm.item.owner;

    if (vm.item.isDestiny1()) {
      if (vm.item.dtrRating && vm.item.dtrRating.userReview) {
        vm.expandReview =
          vm.item.dtrRating.userReview.rating !== 0 &&
          !vm.item.dtrRating.userReview.treatAsSubmitted;
      }
    } else if (vm.item.isDestiny2()) {
      if (vm.item.dtrRating && vm.item.dtrRating.userReview) {
        vm.expandReview =
          vm.item.dtrRating.userReview.voted !== 0 &&
          !vm.item.dtrRating.userReview.treatAsSubmitted;

        if (!vm.item.dtrRating.userReview.mode) {
          vm.item.dtrRating.userReview.mode = settings.reviewsModeSelection;
        }
      }
    }

    vm.reviewData = vm.getReviewData();

    if (vm.item.isDestiny2()) {
      getDefinitions().then((defs) => {
        vm.reviewModeOptions = getReviewModes(defs);
      });
    }
  };

  vm.toggleChart = () => {
    vm.isCollapsed = !vm.isCollapsed;
  };

  vm.procon = false; // TODO: turn this back on..
  vm.aggregate = {
    pros: ['fast', 'lol'],
    cons: ['ok']
  };

  vm.toggleEdit = () => {
    vm.expandReview = !vm.expandReview;

    if (vm.item.isDestiny2() && vm.item.dtrRating && vm.item.dtrRating.userReview.voted !== 0) {
      vm.item.dtrRating.userReview.voted = 0;
      vm.reviewBlur();
    }
  };

  vm.clickReview = (reviewId: string) => {
    const review = this.findReview(reviewId);

    if (review && review.isReviewer) {
      vm.editReview();
    } else if (review && !review.isHighlighted) {
      vm.openFlagContext(reviewId);
    }
  };

  vm.openFlagContext = (reviewId: string) => {
    const review = this.findReview(reviewId);

    if (review && (review.isReviewer || review.isHighlighted)) {
      return;
    }

    const toggledReviewIndex = vm.toggledFlags.indexOf(reviewId);

    if (toggledReviewIndex === -1) {
      vm.toggledFlags.push(reviewId);
    }
  };

  vm.closeFlagContext = (reviewId: string) => {
    const toggledReviewIndex = vm.toggledFlags.indexOf(reviewId);

    vm.toggledFlags.splice(toggledReviewIndex);
  };

  vm.findReview = (reviewId: string): D1ItemUserReview | D2ItemUserReview | null => {
//.........這裏部分代碼省略.........
開發者ID:bhollis,項目名稱:DIM,代碼行數:101,代碼來源:item-review.component.ts


注:本文中的angular.IRootScopeService.%24on方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。