This project was generated with Angular CLI version 9.1.3.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Use
Angular CLI
to init a new Angular 9 client, select enableroute
and usescss
ng new ng9-client
- Use
ng add
to install Angular Material- Choose the prebuild theme
Deep Purple/Amber
- Set up global Angular Material typography styles
N
- Set up brower animations for Angular Material
Y
ng add @angular/material
- Open Transfonter site
- Upload the fonts from the downloaded google fonts, use the default setting and download the coverted zip file.
- Unzip the file and extract the
.woff
and.woff2
for all the fonts and copy these files tosrc/assets/fonts/roboto
- Copy the code from
stylesheet.css
tosrc/assets/scss/modules/_font.scss
- Change the font url to current correct url in
_font.scss
- import the
_font.scss
file in the main stylesheet of the angular applicationstyle.scss
We will create two simple components, and use route to navigate through these two components.
- Create
Home
Component- Create
Profile
Component- Add the route config in
app-routing.module.ts
- Add route outlet in the app html template
app.component.html
, to navigate between theHome
andProfile
component.
- Import
MatToolbarModule
,MatButtonModule
,MatListModule
inapp.module.ts
- Change the application main template
app.component.html
, and use angular material to set the layout.
- Install MSAL libraries
npm install --save @azure/msal-angular msal
- Import MSAL modules in
app.module.ts
const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1; ... MsalModule.forRoot({ auth: { clientId: '00000000-0000-0000-0000-00000000', authority: 'https://login.microsoftonline.com/common', redirectUri: 'http://localhost:4200/', postLogoutRedirectUri: 'http://localhost:4200/', navigateToLoginRequestUrl: true, }, cache: { cacheLocation: 'localStorage', storeAuthStateInCookie: isIE, // set to true for IE 11 }, }, { popUp: !isIE, consentScopes: [ 'user.read', 'openid', 'profile', ], unprotectedResources: [], protectedResourceMap: [ ['https://graph.microsoft.com/v1.0/me', ['user.read']] ], extraQueryParameters: {} }) ], providers: [ { provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: true } ],
Tips:
MSAL informations can be found in AzureApp registrations
, you can refer this blog on how to register an App.
- Add the login and logout functions to the project