gpt4 book ai didi

javascript - Dojo/Angular 范围问题

转载 作者:行者123 更新时间:2023-12-03 09:36:17 25 4
gpt4 key购买 nike

我有一个 dojo 模块,其中包含大量代码,我希望能够使用模块内的函数。该模块在我的 Angular Controller 中加载良好,但我无法使用在我看来 Controller 内部修改的范围。我将如何实现这一目标?这是代码:

angular.controller('mapTestController', ['$rootScope','$scope', function ($rootScope,$scope) {

require(['mapping/scripts/mapping'], function (mapping) {

$scope.TestVar= "How do I access this in my view?";
});

$scope.map = {
center: {
lng: -122.45,
lat: 37.75
},
zoom: 13

};


}]);

HTML:

<div ng-app="AngularApp">
<div ng-controller="mapTestController">
{{TestVar}} //this is blank
...

最佳答案

我不太熟悉 Dojo,但答案可能超出了它的范围。

require(['mapping/scripts/mapping'], function (mapping) {
$scope.$apply(function () {
$scope.TestVar= "How do I access this in my view?";
}
});

关于javascript - Dojo/Angular 范围问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31325224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com