本文整理汇总了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();
}