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

olpath directive doesnot create path if scope variable updates #367

Open
JcDenton86 opened this issue May 9, 2017 · 1 comment
Open

Comments

@JcDenton86
Copy link

JcDenton86 commented May 9, 2017

Hello,

I am trying to build a path using <ol-path coords={{map.path}}></ol-path> and my controller looks like this:

app.controller('mapController', ['$scope','$timeout', function($scope,$timeout) {
    var map = this;
    $timeout(function(){
        map.path = [[[-58.38,-34.60], [-58.58,-34.60],[-58.38,-34.70], [-58.38,-34.80]]];
    }, 250);
}

Debugging your directive the coords array is empty. Instead If I remove the $timeout the path works. The problem is that I am fetching the path dynamically from an API and the building it.
Tried with $digest and $apply and also added $watch in the directive with no result..
Any help is appreciated, thanks

@holgeric
Copy link

Hi,

I had the same issue (ol-path only has a link method, so it won't update once rendered), so I ended up with this workaround:

        <ol-path ng-if="ctrl.pathFlag" coords="{{ctrl.coords}}"></ol-path>
        <ol-path ng-if="!ctrl.pathFlag" coords="{{ctrl.coords}}"></ol-path>
    </openlayers>

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