Skip to content

Unable to use the object with key value 'templateUrl' in angular6 #12488

@cnuwasn

Description

@cnuwasn

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

"@angular-devkit/build-angular": "~0.7.0",
"@angular-devkit/build-ng-packagr": "~0.7.0",
"@angular/cli": "~6.1.5",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^3.0.0",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tsickle": ">=0.29.0",
"tslib": "^1.9.0",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
Angular CLI: 1.6.6

Repro steps

I have the below object in component.ts and I am going to iterate this array in the HTML template inside ui-comp-menu.

menuObject = [{
'labels': 'Content1',
'templateUrl': 'assets/partials/sample.html',
'childrens': [],
},
{
'labels': 'Content2',
'templateUrl': 'assets/partials/sample1.html',
}];

and in the html

<ui-comp-menu [data]="menuObject" [label]="'labels'" [url]="'routeUrl'" >
But while compiling I got the below error

The log given by the failure

ERROR in ./src/app/app.component.ts

Module not found: Error: Can't resolve './assets/partials/UserAdministration.html' in 'D:\POC_Angular_6\lib-demo\src\appI

Desired functionality

It should work even if you give an object with 'templateUrl' as key name

Mention any other details that might be useful

If i change the object key 'templateUrl' to some other name like 'templatePath' issue won't come and compiled successfully.

Similarly 'styleUrl' also not supported.

Ref. this: https://stackoverflow.com/questions/52648392/unable-to-use-the-object-with-key-value-templateurl-in-angular6/52648863#52648863

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions