AngularJS peeps...... I've been given the task of ...
# package-development
c
AngularJS peeps...... I've been given the task of encapsulating the GMaps plugin view within another. I need to get the lat,lng from a custom table in the DB via the outer page, which has it's own controller (done), into GMaps. I'm no angularJS expert but was thinking of a new coords service in the parent controller, but is it possible to inject that into the GMaps controller? I can't find any examples of such a schema. Am I barking up the wrong tree? Sanity check please 🙂
d
Hi Craig, if I remember correctly, anything assigned to the scope of your outer controller, should be available in the scope of your inner controller, so anything you assign to
$scope
should be available. Does that work for you? I think you can also make decorators in angular js, so you could decorate the existing service that the original controller consumes, but I have no experience with that.
c
Thanks for the pointers. I'll take a look. It's basically a rewrite of something that ran on a V7 site with a different Maps package! Just a mess to untangle.
I'm also guessing that if we start to mess with the GMaps code then we need to take the package out of the .proj file so Nuget doesn't overwrite it?
d
Yeah, likely
c
Hmmmm, doesn't seem to work. If I add a $scope.locationCoords with a value to the outer controller, I can view it in the outer parts of the page. But if I add $scope.locationCoords on it's own to the GMaps controller, I can't see it in it's view.
The contruct is a View with an ng-controller of mine.myController. In the View is a section thus:-
Copy code
<umb-property property="property" ng-repeat="property in properties">
    <umb-editor model="property">          </umb-editor>
</umb-property>
Which is what displays the GMaps view with it's own controller.
d
ah, there's a chance that the Umbraco directives overwrite the scope
I don't know how you could achieve this then
c
Ah, right. Thanks.
I tried broadcasting and retrieving but that didn't work either 😦