本文整理匯總了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;
}
});
示例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;
}
});
示例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'});
}));
示例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");
});
示例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);
}
示例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);
});
示例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);
}
}
示例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();
}