Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

This page is relevant to you when you want to create your own Material Angular application for Blueriq using The Angular framework for Blueriq

TODO (Mike)

Change this page and remove what is irrelevant.
And make sure the following is added: 

  • material getting started uitleggen hoe artifactory (staat wel bij redcow...) -> hele getting started bij werken..
  • hoe werkt dit in productie (zie blaadje, maag gliphy van)


Setup Material design 

Go to https://material.angular.io/guide/getting-started

...

  • ng g c page 
    This generates the component in `src\app\page\` including its template, local CSS (Angular simulates a so-called shadow dom in which each component has its own scoped CSS) and spec, or test file. Furthermore, it has added the component in the list of declarations of the `AppModule`.  `ng g c` is shorthand for `ng generate component` 
  • Replace the generated code in `src\app\page\page.component.ts` with the snippet from under:

    Code Block
    import { Component, Host } from '@angular/core';
    import { BlueriqComponent } from '@blueriq/angular';
    import { Page } from '@blueriq/core';
    
    @Component({
      templateUrl: './page.component.html',
      styleUrls: ['./page.component.css'],
    })
    @BlueriqComponent({
      type: Page,
    })
    export class PageComponent {
    
      constructor(@Host() public page: Page) {}
    
    }


    Now write the template:

  •  In `src\app\page\page.component.html` add a simple template using the injected page data: `

    Code Block
    <h1>{{ page.displayName }}</h1>
    
    <div *ngFor="let child of page.children" [bqElement]="child"></div>
     


    The `*ngFor` syntax is Angular's way of implementing a repeat over a list, in this case all children of the page. The `[bqElement]` is an Angular _directive_ that causes the passed `child` object to be rendered using the component that matches. 

    The brackets around `bqElement` cause the argument to be interpreted as TypeScript code. 

    Register as Blueriq component Besides registering the component as an Angular declaration, we also need to register it as a Blueriq component for the `@BlueriqComponent` decorator to be picked up. 

  • In `src\app\app.module.ts` you need to add the following: 

    Code Block
    providers: [
        BlueriqComponents.register([
          PageComponent,
        ]),
      ],
     


    See it in action 

    If `ng serve` is still running, you can immediately open your browser and the page will have automatically refreshed. You should now see the title of the page if everything went well. In Web Inspector, open the console tab and verify that the table with Blueriq components now contains your page component.

...