Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

No error when using controllerAs in directive without an isolated scope #12537

Closed
levin81 opened this issue Aug 10, 2015 · 9 comments
Closed

Comments

@levin81
Copy link

levin81 commented Aug 10, 2015

Using controllerAs inside a directive without an isolated scope doesn't work - as is intended. Only problem is that there is no error in the console in the case of this scenario. It will just fail the entire application.

@Narretz
Copy link
Contributor

Narretz commented Aug 10, 2015

There should probably be an error, that's right. However, what exactly do you mean with "it will fail the entire application"? This simple example works without an issue: http://plnkr.co/edit/FXOQCsD8HI2F3TgpUNnf?p=preview

@levin81
Copy link
Author

levin81 commented Aug 10, 2015

I tried to reproduce it in a simple scenario and I can't seem to. My app has many other directives and they just wouldn't render once I had this issue. If I ever find out, I'll update. Thanks

@brendonco
Copy link

can you paste your HTML and JS or provide the code in jsfiddle or codepen that cause the problem?

@caitp
Copy link
Contributor

caitp commented Aug 12, 2015

There is absolutely no problem with using controllerAs without an isolate scope, why would there be? Yes it's possible to pollute scopes if you don't create a new scope for it, but it's certainly not something you can't do if you're careful

@Narretz
Copy link
Contributor

Narretz commented Aug 21, 2015

@caitp Then we should probably update the docs: https://code.angularjs.org/snapshot/docs/api/ng/service/$compile#-controlleras- ;)

@caitp
Copy link
Contributor

caitp commented Aug 21, 2015

Those docs don't say anything about out being only for isolate scopes

@Narretz
Copy link
Contributor

Narretz commented Aug 21, 2015

That's right. They do however say you need a new scope, but it also works without a new scope. I'll create a PR to make this clearer.

Narretz added a commit to Narretz/angular.js that referenced this issue Sep 4, 2015
@Narretz
Copy link
Contributor

Narretz commented Sep 4, 2015

@caitp can you please take a look at #12758?

Narretz added a commit to Narretz/angular.js that referenced this issue Sep 7, 2015
Narretz added a commit to Narretz/angular.js that referenced this issue Sep 7, 2015
@Narretz Narretz closed this as completed in 80a2176 Sep 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants