此函数内的范围值不更新视图。
我尝试在所有范围值下方添加$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>;
点击标记我在地图的右侧显示此信息。左侧我正在显示地图,右侧有关我正在显示的标记的信息。