Skip to content
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

bug: controllerAs syntax in ion-view #3058

Closed
thaiat opened this issue Feb 9, 2015 · 35 comments
Closed

bug: controllerAs syntax in ion-view #3058

thaiat opened this issue Feb 9, 2015 · 35 comments
Milestone

Comments

@thaiat
Copy link

thaiat commented Feb 9, 2015

Type: bug

Platform: all

There is still an issue with the controllerAs syntax and ion-view (beta 14)

this issue #2499 is still happening
here is a repro codepen: http://codepen.io/thaiat/pen/zxPMbL

if you change line 16 to the commented part, it's working
The issue is related to views in state

@thaiat thaiat changed the title controllerAs syntax in ion-view bug: controllerAs syntax in ion-view Feb 9, 2015
@asfktz
Copy link

asfktz commented Feb 26, 2015

👍

@AliMD
Copy link

AliMD commented Mar 12, 2015

👍
temporary solution: controller: 'pageController as ctrl'

@antonellopasella
Copy link

still using the temporary solution...
ng-controller: 'pageController as ctrl'

@elebetsamer
Copy link

Would be great if the controllerAs syntax was supported. I'm just trying to change my code to adhere more closely to john papa's fabulous angular style guide and I just spent an hour trying to figure out what I was doing wrong by using controllerAs: 'vm' only to find out that this is an ionic problem.

@srameshr
Copy link

@elebetsamer Same with me! I spent an hour trying to make controllerAs syntax with Ionic. Even I am following john papa's style guide! But what about when using es6? His style guide has minor issues with respect to es6?

@elebetsamer
Copy link

@SiddharthaRRamesh I'm not crossing that bridge yet. Think I'm going to wait for angular 2 and ionic 2 before worrying about it.

@ace-han
Copy link

ace-han commented Apr 21, 2015

@elebetsamer, @SiddharthaRRamesh, Yes, I was following john papa's fabulous angular style guide, too. Only to find out ionic currently works with controller: 'XxxController as vm'. I think we might as well follow this style now

@sodatea
Copy link

sodatea commented Apr 30, 2015

@SiddharthaRRamesh I use ES6 with ionic too. To circumvent this issue, I injected $scope into the controller class and assigned this to $scope.ctrl. Thus I don't have to change my template markup and it just looks as if the controllerAs syntax worked.This trick works well in my app.

My code looks like this:

class LoginController {
  constructor($scope) {
    $scope.ctrl = this;
  }
  // some method definitions...
}

LoginController.$inject = ['$scope'];

urish added a commit to urish/ionic that referenced this issue May 1, 2015
@urish
Copy link

urish commented May 1, 2015

Just sent PR #3651 to fix this issue. Hopefully it will be merged soon :)

@thaiat
Copy link
Author

thaiat commented May 1, 2015

@urish you are everywhere !!!!! ;)

@urish
Copy link

urish commented May 1, 2015

Same with you @thaiat :)

p.s. here is the repro codepen with the fixed ionic version: http://codepen.io/anon/pen/QbbQPo

@andrewharry
Copy link

+1 Would love for this to be resolved!

@novarac23
Copy link

+1 for this being resolved! Thanks to @urish hopefully this will be resolved soon 👍

@ashishdasnurkar
Copy link

+1 would be great to make this work

@ClemMakesApps
Copy link

+1 looking forward to having this added as well

@mlix11
Copy link

mlix11 commented Jun 11, 2015

+1 please make it happend

@cmartin81
Copy link

+1

1 similar comment
@jiwhiz
Copy link

jiwhiz commented Jul 10, 2015

+1

@TankMasterRL
Copy link

Very annoying bug, please fix this!

@shmendo
Copy link

shmendo commented Jul 16, 2015

+1

@srameshr
Copy link

Please see us @Ionitron

@leandroz
Copy link

I cant believe that something trivial as controllerAs is not working.

@urish
Copy link

urish commented Jul 23, 2015

@perrygovier can you please look into merging this?

it's a small change, and will help many people. Thanks!

@rockyromano
Copy link

+1

1 similar comment
@larsar
Copy link

larsar commented Jul 25, 2015

+1

@clemfernandez
Copy link

definitely need this to be fixed, mustn't be that complicated to fix since the controller: 'controller as vm' syntax is working fine!

@urish
Copy link

urish commented Jul 26, 2015

@clmntfrndz the fix is already available in #3651, but hasn't been merged in yet

@mhartington mhartington added this to the 1.1 milestone Jul 26, 2015
@mikeLspohn
Copy link

Any expected timeline of when this will be merged in yet and fixed?

@ClemMakesApps
Copy link

Looks like it's set for 1.1 release

@diegognt
Copy link

Please make that this happen

@cmartin81
Copy link

It is not fixed in the 1.1 release :(

@mhartington mhartington modified the milestones: 1.1, 1.2 Aug 15, 2015
@telemakhos
Copy link

Why is the fix not being merged? well, I guess we'll have to patch it ourselves...

@mhartington
Copy link
Member

@telemakhos please check out the PR, I have addressed this.

There were a few other things that took priority. Will revisit this.
You can still use controller as though, nothing is preventing you from doing so

controller: 'MainCtrl as main'

@telemakhos
Copy link

@mhartington ah! ok! I think that'll do the trick

@someone235
Copy link

+1

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests