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

Properties added through data are assigned to this and this.$ #39

Closed
MikaAK opened this issue Dec 20, 2014 · 2 comments
Closed

Properties added through data are assigned to this and this.$ #39

MikaAK opened this issue Dec 20, 2014 · 2 comments

Comments

@MikaAK
Copy link

MikaAK commented Dec 20, 2014

Recently I noticed that data that has been assigned via the data: {} property will not only get put on this.$ but also on this.
Assigning properties via this.$.myProp = { a: 1, b: 2} only inserts them on scope and doesn't put them onto the this object of the controller.

@davej
Copy link
Owner

davej commented Dec 21, 2014

Yes, this is for zero-config compatibility with both $scope-style controllers and controllerAs (#4) controllers.

You can turn off binding to the $scope (this.$) by setting the addToScope option to false.

myApp.classy.options.controller = {
    bindData: {
        addToScope: false
    }
}

You can't currently prevent binding to this but I think that's a reasonable feature request so I will add it to Classy sometime this week.

@davej davej closed this as completed in c42233c Jan 6, 2015
@davej
Copy link
Owner

davej commented Jan 6, 2015

This is now fixed in master.

Example Usage:

angular.module('app').classy.options.controller = {
    bindData: {
        addToClass: false
    }
}

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

No branches or pull requests

2 participants