简体   繁体   中英

Angular 1.6.x , how to render component tag from current component to html

I want to call already registered angular component(another) from a current component file to HTML but in HTML it's reading as String.

The code below, is im trying out in component file,

$scope.component = "<complaint-create-component></complaint-create-component>;

I tried ng-bind-HTML expression to call but that also reading as String. if I use this component name (<complaint-create-component></complaint-create-component>) directly into HTML file it's working fine(As expected).

Presently I'm using angular 1.6 version.

Please help me out.

尝试使用$sce.trustAsHtml

$scope.component= $sce.trustAsHtml("<complaint-create-component></complaint-create-component>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM