Questions tagged [angular2-compiler]

30 questions
210
votes
15 answers

How can I use/create dynamic template to compile dynamic Component with Angular 2.0?

I want to dynamically create a template. This should be used to build a ComponentType at runtime and place (even replace) it somewhere inside of the hosting Component. Until RC4 I was using ComponentResolver, but with RC5 I get the following…
Radim Köhler
  • 117,533
  • 47
  • 231
  • 321
139
votes
9 answers

Equivalent of $compile in Angular 2

I want to manually compile some HTML containing directives. What is the equivalent of $compile in Angular 2? For example, in Angular 1, I could dynamically compile a fragment of HTML and append it to the DOM: var e = angular.element('
pixelbits
  • 48,078
  • 15
  • 86
  • 124
46
votes
5 answers

Dynamically load HTML template in angular2

I have created a project using angular-cli which contains AppComponent as follows: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export…
Partha Sarathi Ghosh
  • 8,730
  • 18
  • 53
  • 79
6
votes
4 answers

Angular 2 RC 6 AoT Compiler not working

I just updated my project to Angular 2 RC 6. I am now trying to use Ahead of Time (AoT) Compilation as mentioned in blog post http://angularjs.blogspot.com/ but no success. I am not using angular cli as I building project in ASP.Net. As the blog…
Naveed Ahmed
  • 8,391
  • 11
  • 39
  • 75
5
votes
3 answers

Add custom elements and attributes to compiler schema

There are some custom elements and attributes in component template (in this example they are used by third-party non-Angular code):
They cause a compiler error: Template parse errors: 'foo' is not a…
Estus Flask
  • 150,909
  • 47
  • 291
  • 441
5
votes
2 answers

How to use RouterModule.forRoot() in Angular2 compiler/cli ngc command

Let's say i have the following appRoutingModule: export const routes: Route[] = [ { path: '', component: ApplicationlistComponent } ]; @NgModule( { imports: [ ApplicationsModule, RouterModule.forRoot( routes ) ], exports: […
Piet K
  • 91
  • 1
  • 7
5
votes
0 answers

Angular2 RC5 dynamically compile component with correct module

I'm trying to use the angular2 compiler to dynamically insert a component, which works fine as long as all code is in the default module. But if try to put the component into it's own feature module, it breaks. The injected compiler instance…
nuVoid
  • 221
  • 1
  • 5
4
votes
1 answer

Typescript 2.1 coupled with the Angular 2 compiler silently fails to compile project files (no output)

Using the following typescript and angular compiler configuration: tsconfig.json { "compilerOptions": { "target": "es5", "module": "es2015", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, …
Kesarion
  • 2,459
  • 5
  • 28
  • 47
4
votes
1 answer

"Can't read the url" error for angular2 dynamic components with templateUrl

Tried to modify soultion from here. It works fine, but if you change template to templateUrl in component, that should load dynamically, you get an error: "No ResourceLoader implementation has been provided. Can't read the url ...". @Component({ …
Max
  • 43
  • 4
3
votes
1 answer

Angular2 Universal error Cannot find module '@angular/compiler/src/template_parser' after upgrading to RC5

Am using angular2 ,webpack and angular universal the project builds fine but I get the following error at runtime. Works fine with angular RC4 Error: Cannot find module '@angular/compiler/src/template_parser' at Function.Module._resolveFilename…
kabangi julius
  • 1,779
  • 1
  • 14
  • 24
2
votes
0 answers

Angular 2 compiler trouble picking up interface import

I'm have project that I was previously building with webpack + awesome-typescript-loader and am trying to use ngc so that I can do AOT compilation. However, when run ngc "node_mdoules/.bin/ngc" -p tsconfig-aot.json I get an error: Error at…
somnid
  • 57
  • 5
2
votes
0 answers

Angular 2 JIT Compiler very strange behavior

I recently updated from angular 2.3.1 to 2.4.7, and I've found a very strange behavior, That's the code: UpcomingGames.html
Serginho
  • 6,213
  • 2
  • 21
  • 45
2
votes
0 answers

Ionic 2 - How to create dynamic template to compile dynamic component

I want to dynamically create a template. I found a resolution that works with Angular 2.0, this resolution uses a JiT compiler. Link to resolution in Angular 2.0 My question is, how to make dynamically created template using Ionic 2? Can I use…
user7306926
2
votes
1 answer

Unknown compiler option 'angularCompilerOptions' in angular 2 ahead-of-time compilation

I'm trying to use AOT compiler in this angular 2 project. I get error: TypeError: this.compiler.compileModules is not a function when I execute command: "node_modules/.bin/ngc" -p tsconfig-aot.json . How to solve this issue? Steps to…
Ildar
  • 3,111
  • 3
  • 35
  • 66
2
votes
1 answer

recursive dynamic template compilation in angular2

I've based some of my work on the same problem described in here: dynamic template to compile dynamic Component with Angular 2.0 How can I use/create dynamic template to compile dynamic Component with Angular 2.0? The working plunker described in…
1
2