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

$watch controller memebers independent controllerAs allias #780

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

$watch controller memebers independent controllerAs allias #780

wants to merge 1 commit into from

Conversation

gilhanan
Copy link

@gilhanan gilhanan commented Sep 22, 2016

Watching controller members should not be depend on the controllerAs alias name, it's hard to maintenance, and can make confusing when using multiple instances of the controller in view.

watching controller members should not be depend on chosen controllerAs alias name, it's hard to maintenance, and can make confusing by using multiple instance of controller.
@thatkookooguy
Copy link

@gilhanan what's the difference? you used it inside your function, and the original uses the syntactic sugar as a string. but both have vm.title.

so, mostly the difference is that in your version it takes up some more space since it requires you to write another function.

@gilhanan
Copy link
Author

gilhanan commented Nov 9, 2016

@thatkookooguy The difference is when using the syntactic sugar, you have to use the variable declared in the scope, which can be confuse and hard to maintenance, because it's managed outside the the function.

For example if one day you rename the controllerAs allias or remove it, you have to refactor your watches

@thatkookooguy
Copy link

@gilhanan oh now I understand. But if you follow the entire style-guide, the controllerAs name is always related to the actual controller name. So, you should change all your $watches or your controllerAs names, as much as your change your controller names, which shouldn't be too often.

so there's not too much to remember or to get confused by if you keep the style of the entire style-guide eco-system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants