-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19850 from abpframework/issue-19834
Update title strategy service to get project name from localized text
- Loading branch information
Showing
8 changed files
with
105 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Title Strategy For Angular | ||
|
||
## **ABP has a default title strategy for Angular UI**. | ||
|
||
This strategy is based on the title property. Provide a title property when setting a new route. | ||
|
||
**Example** | ||
|
||
```ts | ||
{ | ||
path: 'customers', | ||
component: CustomersComponent, | ||
title: 'AbpCustomers::Roles' | ||
}, | ||
``` | ||
|
||
- It is better to use localized text in the title property. It will be translated by **LocalizationService**. | ||
- The **`title`** property is already set in **ABP internal packages**. | ||
|
||
## How it looks | ||
|
||
When you create a new route and provide a **`title`** property, it will look like this **`<title> | <projectName>`** | ||
|
||
### What is `projectName` and How to Customize | ||
|
||
- **`projectName`** is the name of your application. By default, ABP sets a [**`projectName`**](https://github.com/abpframework/abp/blob/f48f78618a326644843c01424b093f0d79448769/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectName/en.json#L4) for your application. This localization text is added for customization and can be changed for different languages. | ||
|
||
### Disable `projectName` | ||
|
||
- If you don't want to show **`projectName`** in the title, you can disable it. | ||
|
||
**app.module.ts** | ||
|
||
```ts | ||
import { DISABLE_PROJECT_NAME } from '@abp/ng.core'; | ||
|
||
providers: [ | ||
..., | ||
{ provide: DISABLE_PROJECT_NAME, useValue: true} | ||
], | ||
``` | ||
|
||
- Now only title will be shown. | ||
|
||
## Override ABP's Default Title Strategy | ||
|
||
**app.module.ts** | ||
|
||
```ts | ||
import { TitleStrategy } from '@angular/router'; | ||
import { YourCustomStrategy } from './title-strategy.service.ts'; | ||
|
||
providers: [ | ||
..., | ||
{ provide: TitleStrategy, useExisting: YourCustomStrategy }, | ||
], | ||
``` | ||
|
||
- You can check [Angular Documentation](https://angular.io/api/router/TitleStrategy) to write a custom **`TitleStrategy`**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
npm/ng-packs/packages/core/src/lib/tokens/title-strategy-disable-project-name.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
export const DISABLE_PROJECT_NAME = new InjectionToken<boolean>('DISABLE_APP_NAME'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>DevApp</title> | ||
<base href="/"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>MyProjectName</title> | ||
<base href="/" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
</html> |