T
T
TheRevan2016-09-29 11:45:19
Angular
TheRevan, 2016-09-29 11:45:19

Is it possible to use a template engine with Angular?

Is it possible to use template engines with angular? is this common practice? Are there any projects built on them? If so, how to insert php info into typescript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Lopatin, 2016-09-29
@TheRevan

Everything is possible.
Method number one:

@Component({
  templateUrl: 'your-smarty-template.php'
})

Method number two:
@Component({
  template: '<div [innerHTML]="myHtml"></div>'
})
export class MyComponent implements OnInit {

  myHtml?: SafeHtml;

  constructor(private _http: Http, private _sanitizer: DomSanitizer) {
  }

  ngOnInit() {
    this._http.get("your-smarty-template.php")
      .subscribe(response =>
        this.myHtml = this._sanitizer.bypassSecurityTrustHtml(response.text()));
  }

}

But why this is necessary is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question