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


TypeScript Location.go方法代碼示例

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


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

示例1: if

            .subscribe(currentMail => {
                if ( !currentMail )
                {
                    // Set the current mail id to null to deselect the current mail
                    this.currentMail = null;

                    // Handle the location changes
                    const labelHandle  = this._activatedRoute.snapshot.params.labelHandle,
                          filterHandle = this._activatedRoute.snapshot.params.filterHandle,
                          folderHandle = this._activatedRoute.snapshot.params.folderHandle;

                    if ( labelHandle )
                    {
                        this._location.go('apps/mail/label/' + labelHandle);
                    }
                    else if ( filterHandle )
                    {
                        this._location.go('apps/mail/filter/' + filterHandle);
                    }
                    else
                    {
                        this._location.go('apps/mail/' + folderHandle);
                    }
                }
                else
                {
                    this.currentMail = currentMail;
                }
            });
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:29,代碼來源:mail-list.component.ts

示例2: if

            .subscribe(currentTodo => {
                if ( !currentTodo )
                {
                    // Set the current todo id to null to deselect the current todo
                    this.currentTodo = null;

                    // Handle the location changes
                    const tagHandle    = this._activatedRoute.snapshot.params.tagHandle,
                          filterHandle = this._activatedRoute.snapshot.params.filterHandle;

                    if ( tagHandle )
                    {
                        this._location.go('apps/todo/tag/' + tagHandle);
                    }
                    else if ( filterHandle )
                    {
                        this._location.go('apps/todo/filter/' + filterHandle);
                    }
                    else
                    {
                        this._location.go('apps/todo/all');
                    }
                }
                else
                {
                    this.currentTodo = currentTodo;
                }
            });
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:28,代碼來源:todo-list.component.ts

示例3: it

    it('should work after using back button', inject([Location], (location: Location) => {

         expect(location.getState()).toBe(null);

         location.go('/test1', '', {url: 'test1'});
         location.go('/test2', '', {url: 'test2'});

         expect(location.getState()).toEqual({url: 'test2'});

         location.back();

         expect(location.getState()).toEqual({url: 'test1'});
       }));
開發者ID:marclaval,項目名稱:angular,代碼行數:13,代碼來源:location_spec.ts

示例4: it

    it('should incorporate the provided query values into the location change', () => {
      var locationStrategy = new MockLocationStrategy();
      var location = new Location(locationStrategy);

      location.go('/home', "key=value");
      expect(location.path()).toEqual("/home?key=value");
    });
開發者ID:Coco-wan,項目名稱:angular,代碼行數:7,代碼來源:location_spec.ts

示例5: readMail

    // -----------------------------------------------------------------------------------------------------
    // @ Public methods
    // -----------------------------------------------------------------------------------------------------

    /**
     * Read mail
     *
     * @param mailId
     */
    readMail(mailId): void
    {
        const labelHandle  = this._activatedRoute.snapshot.params.labelHandle,
              filterHandle = this._activatedRoute.snapshot.params.filterHandle,
              folderHandle = this._activatedRoute.snapshot.params.folderHandle;

        if ( labelHandle )
        {
            this._location.go('apps/mail/label/' + labelHandle + '/' + mailId);
        }
        else if ( filterHandle )
        {
            this._location.go('apps/mail/filter/' + filterHandle + '/' + mailId);
        }
        else
        {
            this._location.go('apps/mail/' + folderHandle + '/' + mailId);
        }

        // Set current mail
        this._mailService.setCurrentMail(mailId);
    }
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:31,代碼來源:mail-list.component.ts

示例6:

            .then(() => {

                // Trigger the subscription with new data
                this._ecommerceProductService.onProductChanged.next(data);

                // Show the success message
                this._matSnackBar.open('Product added', 'OK', {
                    verticalPosition: 'top',
                    duration        : 2000
                });

                // Change the location with new one
                this._location.go('apps/e-commerce/products/' + this.product.id + '/' + this.product.handle);
            });
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:14,代碼來源:product.component.ts

示例7: setCurrentTodo

    /**
     * Set current todo by id
     *
     * @param id
     */
    setCurrentTodo(id): void
    {
        this.currentTodo = this.todos.find(todo => {
            return todo.id === id;
        });

        this.onCurrentTodoChanged.next([this.currentTodo, 'edit']);

        const tagHandle    = this.routeParams.tagHandle,
              filterHandle = this.routeParams.filterHandle;

        if ( tagHandle )
        {
            this._location.go('apps/todo/tag/' + tagHandle + '/' + id);
        }
        else if ( filterHandle )
        {
            this._location.go('apps/todo/filter/' + filterHandle + '/' + id);
        }
        else
        {
            this._location.go('apps/todo/all/' + id);
        }
    }
開發者ID:karthik12ui,項目名稱:fuse-angular-full,代碼行數:29,代碼來源:todo.service.ts

示例8: navigate

	// ---
	// PUBLIC METHODS.
	// ---

	// I navigate to the given URL. This URL is expected to be a "complete" URL; meaning,
	// it contains all the necessary components: pathname, query-string, and hash.
	public navigate( newPath: string ) : void {

		// In the documentation, the .go() method accepts two arguments: "path" and 
		// "query". This leaves you wondering about the "hash" - where does that go? 
		// Well, it turns out that the path and query don't really need to be broken out
		// into separate components. Under the hood, they are just concatenated. As such,
		// we can include them in the "path" argument, along with any desired HASH value.
		this.location.go( newPath );

		// Since the PopStateEvent doesn't fire when we programmatically navigate, let's
		// turn around and query the location.
		console.group( "Internal Navigation" );
		console.log( this.location.path() );
		console.groupEnd();

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:22,代碼來源:app.component.ts


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