Ludo Ludo - 1 year ago 122
AngularJS Question

Use openlayers-directive inside a directive

I'm trying to use openlayers-directive inside a directive:

var app = angular.module("demoapp", ["openlayers-directive"]);
app.directive('myDir', function () {
return {
restrict: "E",
replace: true,
template: "<openlayers ol-center='center' height='480px' width='640px'></openlayers>"

In html:


But when I'm doing this, I have a multi-dir error

VM2731 angular.js:12221 Error: [$compile:multidir] Multiple directives [myDir, openlayers] asking for template on: <openlayers ol-center="center" height="480px" width="640px">

Any explanation will be usefull


Here is the fiddle

Answer Source

Your directive's template should have its own root <div>, inside it will be placed the open-layers directive. This way you're defining a separate template in which the nested directive can be compiled.

template: "<div><openlayers ol-center='center' height='480px' width='640px'></openlayers></div>"