Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

New methods #86

Open
xgrommx opened this issue Jun 25, 2015 · 2 comments
Open

New methods #86

xgrommx opened this issue Jun 25, 2015 · 2 comments

Comments

@xgrommx
Copy link
Contributor

xgrommx commented Jun 25, 2015

Hello @mattpodwysocki. What about if I'll implement couple operators like a assignProperty and assignProperties? They should be use so:

obs.$assignProperty(scope or controller, 'property');
obs.$assignProperties(scope or controller, ['property1', 'property2']);
@sirbarrence
Copy link
Contributor

+1

I was just about to implement something like this myself. Just to make sure I understand, is this supposed to be a shortcut for

someObservable.safeApply($scope, function(value) {
    this.prop = value; // when using controllerAs
    // or
    $scope.prop = value;
}).subscribe();

Because that's what I'm looking for.

Wouldn't the $assignProperty operator always need a scope as the first argument so it can delegate to safeApply internally? Even when setting a controller property & using the controllerAs syntax, I think you still have to invoke a $apply() on a Scope instance to get Angular to notice the change.

@mattpodwysocki is this something you'd be interested in accepting?

@sirbarrence
Copy link
Contributor

Looks like this already exists as .digest(), but it's not documented.

// assign someObservable's values to $scope.myProperty, then run a digest if necessary.
someObservable
    .digest($scope, 'myProperty')
    .subscribe();

// assign someObservable's values to a controller property `myProperty`, then run a digest if necessary.
someObservable
    .digest($scope, 'ctrl.myProperty')
    .subscribe();

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

2 participants