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 CLIto init a new Angular 9 client, select enablerouteand usescss
ng new ng9-client
- Use
ng addto 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
.woffand.woff2for all the fonts and copy these files tosrc/assets/fonts/roboto- Copy the code from
stylesheet.csstosrc/assets/scss/modules/_font.scss- Change the font url to current correct url in
_font.scss
- import the
_font.scssfile 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
HomeComponent- Create
ProfileComponent- Add the route config in
app-routing.module.ts- Add route outlet in the app html template
app.component.html, to navigate between theHomeandProfilecomponent.
- Import
MatToolbarModule,MatButtonModule,MatListModuleinapp.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.tsconstisIE=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






