谷歌地图事件监听器内的范围值未进入视图

时间:2017-11-07 12:47:46

标签: javascript angularjs

此函数内的范围值不更新视图。 我尝试在所有范围值下方添加$scope.$apply();,请帮助我。 $rootScope能够获取$scope值的google.maps.event.addListener(marker, 'click', (function(marker, $scope, $rootScope) { return function() { if ($rootScope.showMobile) { $scope.cityDetail(); $scope.placehoderInfo = false; $scope.pencilfirst = marker.information + '' + ',' + marker.state + '-' + marker.pin_zip; $scope.name_of_business = marker.name_of_business; $scope.$apply(); } else { $rootScope.showDetails = false; $scope.pencilsecond = marker.information + '' + ',' + marker.state + '-' + marker.pin_zip; $rootScope.showwithOutMob = true; $scope.$apply(); } }; })(marker, $scope, $rootScope)); 值。

<div   ng-show="showDetails">
   <h4 class="text_display">{{pencilfirst}}</h4>
</div>

<div   ng-show="showwithOutMob">
   <h4 class="text_display">{{pencilsecond}}</h4>
</div>

HTML代码

/**
 * Retrieve the elements represented by the ElementArrayFinder. The input
 * function is passed to the resulting promise, which resolves to an
 * array of ElementFinders.
 *
 * @alias element.all(locator).then(thenFunction)
 * @view
 * <ul class="items">
 *   <li>First</li>
 *   <li>Second</li>
 *   <li>Third</li>
 * </ul>
 *
 * @example
 * element.all(by.css('.items li')).then(function(arr) {
 *   expect(arr.length).toEqual(3);
 * });
 *
 * // Or using the shortcut $$() notation instead of element.all(by.css()):
 *
 * $$('.items li').then(function(arr) {
 *   expect(arr.length).toEqual(3);
 * });
 *
 * @param {function(Array.<ElementFinder>)} fn
 * @param {function(Error)} errorFn
 *
 * @returns {!webdriver.promise.Promise} A promise which will resolve to
 *     an array of ElementFinders represented by the ElementArrayFinder.
 */
then<T>(fn?: (value: ElementFinder[] | any[]) => T | wdpromise.IThenable<T>, errorFn?: (error: any) => any): wdpromise.Promise<T>;

点击标记我在地图的右侧显示此信息。左侧我正在显示地图,右侧有关我正在显示的标记的信息。

0 个答案:

没有答案