Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cnuwasn opened this issue Oct 5, 2018 · 3 comments · Fixed by #12503
Closed

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

cnuwasn opened this issue Oct 5, 2018 · 3 comments · Fixed by #12503
Assignees
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken

Comments

@cnuwasn
Copy link

cnuwasn commented Oct 5, 2018

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

@alan-agius4 alan-agius4 added needs: repro steps We cannot reproduce the issue with the information given and removed needs: repro steps We cannot reproduce the issue with the information given labels Oct 5, 2018
@alan-agius4
Copy link
Collaborator

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

@cnuwasn
Copy link
Author

cnuwasn commented Oct 5, 2018

please find the attached sample here. please do npm install before ng serve

https://github.com/cnuwasn/cli_bug

@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: @ngtools/webpack and removed needs: repro steps We cannot reproduce the issue with the information given labels Oct 5, 2018
@alan-agius4 alan-agius4 self-assigned this Oct 5, 2018
vikerman pushed a commit that referenced this issue Nov 8, 2018
…orators (#12503)

At the moment we are processing all property assignments in object literals irrespective if they are in a decorator or not. With this change we will process only property assignments found under in a component decorator.

Fixes #12488, Fixes #6007, Fixes: #6498 and Fixes: #8295
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
ikjelle pushed a commit to ikjelle/angular-cli that referenced this issue Mar 26, 2024
…orators (angular#12503)

At the moment we are processing all property assignments in object literals irrespective if they are in a decorator or not. With this change we will process only property assignments found under in a component decorator.

Fixes angular#12488, Fixes angular#6007, Fixes: angular#6498 and Fixes: angular#8295
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants