自定义指令范围元素可见但未定义

Custom directive scope element visible but undefined

我制作了一个从控制器检索数据的自定义指令。

我的变量在作用域元素内可见,但在尝试访问它时,我得到 undefined

HTML

<map borders="vm.borders"></map>

指令

angular.module('myApp.directives')
.directive('map', [ function() {
    return {
        restrict: 'E',
        scope: {
            borders: '='
        },
        link: function(scope, element, attrs) {
            console.log(scope); //cfr linked image
            console.log(scope.borders) //undefined
        }
    }
}]);

这是范围。它包含边界变量。

我缺少什么来检索这个边框值?

我建议在指令中添加一个 ng-if,因为例如,如果 vm.borders 是从承诺中获得的,则需要 ng-if

<map borders="vm.borders" ng-if="vm.borders"></map>