我正在尝试使用 ngMap 指令之一创建自定义指令。形状,具体来说。
angular
.module('seeMeApp', ['ngMap'])
.directive('userPath', function () {
return {
restrict: 'E',
scope: {
user: '=userObj',
weight: '=',
opacity: '='
},
replace: true,
template: '<shape name="polyline" path="{{user.pathCoordinates}}" geodesic="true" stroke-color="{{user.color}}" stroke-opacity="{{opacity}}" stroke-weight="{{weight}}"></shape>'
};
})
当我直接在 ngMap 的 map 指令中使用 shape 指令时,模型的变化会被插值并反映在 map 上。
<map ng-show="pathCoordinates.length > 0" center="{{pathCoordinates[pathCoordinates.length - 1]}}" zoom="15">
<shape ng-if="pathCoordinates.length > 0" name="polyline" path="{{pathCoordinates}}" geodesic="true"
stroke-color="{{mapConfig.color}}" stroke-opacity="{{mapConfig.opacity}}" stroke-weight="{{mapConfig.stroke}}"> </shape>
</map>
但是当我使用 Shape 创建自定义指令时,dom 会发生变化,但在 Map 上没有创建可见的形状。
我在这里创建了一个 plunker:
http://plnkr.co/qrRxYxORvdKdLANg50Yn
我错过了什么。谢谢