@builder.io/angular
TypeScript icon, indicating that this package has built-in type declarations

1.0.45-alpha.2 • Public • Published

Builder Angular SDK

Usage

Install

npm install --save @builder.io/angular

Add the module

import { BuilderModule } from '@builder.io/angular';

@NgModule({
  ...
  imports: [ BuilderModule.forRoot('YOUR_API_KEY') ],
  ...
})
export class MyAppModule { }

And then add the component wherever you like, and you are done!

<!-- The model input can be any model of yours -->
<builder-component model="page" (load)="contentLoaded($event)" (error)="contentError($event)">
  <!-- Default content inside the tag shows while the builder content is fetching -->
  <div class="spinner"></div>
</builder-component>

Custom landing pages in your code

Simply replace your 404 component with something like the below to allow creating new pages in Builder easily

<!-- The model input can be any model of yours -->
<builder-component
  *ngIf="!noBuilderPageForUrl"
  model="page"
  (load)="noBuilderPageForUrl = $event ? false : true"
  (error)="noBuilderPageForUrl = true"
>
  <!-- Default content inside the tag shows while the builder content is fetching -->
  <div class="spinner"></div>
</builder-component>
<my-404-component *ngIf="noBuilderPageForUrl"> </my-404-component>

Use your angular components in your Builder pages

You can drag and drop to add your angular components in the Builder editor with a simple tag like below:

import { BuilderBlock } from '@builder.io/angular';
import { Component, Input } from '@angular/core';

@BuilderBlock({
  tag: 'custom-thing',
  name: 'Custom thing',
  inputs: [
    {
      name: 'name',
      type: 'string',
    },
  ],
})
@Component({
  selector: 'custom-thing',
  template: 'Hello: {{name}}',
})
export class CustomThing {
  @Input()
  name = '';
}

See here for full detail on input types available.

Visual of using your Angular component in Builder

Use your state or functions in your Builder pages

Use the data input for the Builder component tag to pass down data and actions to be used in the Builder editor.

See this guide for usage of your data and actions in the editor UI in Builder.

@Component({
  selector: 'my-page',
  template: '<builder-component name="page" [data]="data"></builder-component>',
})
export class MyPage {
  data = {
    someStateProperty: 'foo',
    someMethod: () => /* do something */,
    myService: this.myService
  }

  constructor(public myService: MyService) {

  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @builder.io/angular@1.0.45-alpha.2

Version

1.0.45-alpha.2

License

MIT

Unpacked Size

1.34 MB

Total Files

167

Last publish

Collaborators

  • steve8708
  • samijaber
  • teleaziz123
  • mrkoreye
  • strd6
  • mhevery
  • adamdbradley
  • gustavohgs
  • manucorporat
  • shyam-builder
  • sanyamkamat
  • harmeet.builder
  • midhunadarvin
  • kylefowler
  • builderio-bot
  • armela
  • anaghavarhade
  • sidmohanty11
  • yash-wadhia-builder
  • paprikaf
  • clyde-builderio