ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: controllerAs syntax in ion-view

Open thaiat opened this issue 11 years ago • 35 comments

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 avatar Feb 09 '15 07:02 thaiat

:+1:

asfktz avatar Feb 26 '15 10:02 asfktz

:+1: temporary solution: controller: 'pageController as ctrl'

alimd avatar Mar 12 '15 16:03 alimd

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

antonellopasella avatar Mar 30 '15 09:03 antonellopasella

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.

elebetsamer avatar Apr 15 '15 01:04 elebetsamer

@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?

srameshr avatar Apr 15 '15 06:04 srameshr

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

elebetsamer avatar Apr 15 '15 08:04 elebetsamer

@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

ace-han avatar Apr 21 '15 17:04 ace-han

@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'];

haoqunjiang avatar Apr 30 '15 14:04 haoqunjiang

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

urish avatar May 01 '15 12:05 urish

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

thaiat avatar May 01 '15 12:05 thaiat

Same with you @thaiat :)

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

urish avatar May 01 '15 15:05 urish

+1 Would love for this to be resolved!

andrewharry avatar May 20 '15 03:05 andrewharry

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

novarac23 avatar May 23 '15 08:05 novarac23

+1 would be great to make this work

ashishdasnurkar avatar Jun 07 '15 13:06 ashishdasnurkar

+1 looking forward to having this added as well

ClemMakesApps avatar Jun 08 '15 20:06 ClemMakesApps

+1 please make it happend

mlix11 avatar Jun 11 '15 07:06 mlix11

+1

cmartin81 avatar Jul 08 '15 20:07 cmartin81

+1

jiwhiz avatar Jul 10 '15 15:07 jiwhiz

Very annoying bug, please fix this!

TankMasterRL avatar Jul 13 '15 17:07 TankMasterRL

+1

shmendo avatar Jul 16 '15 21:07 shmendo