相关疑难解决方法(0)

在AngularJS中使用$ timeout而不是window.setTimeout有什么好处?

我有一个建议实现这样的超时:

  $timeout(function() {

    // Loadind done here - Show message for 3 more seconds.
    $timeout(function() {
      $scope.showMessage = false;
    }, 3000);

  }, 2000);
};
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我使用它而不是使用setTimeout的原因/优势是什么?

settimeout angularjs

50
推荐指数
2
解决办法
7万
查看次数

AngularJS:在标签中通过Google Maps API v3进行映射

我正在尝试使用选项卡创建一个页面(使用AngularJS).其中一个标签中有一张地图(Google Maps API v3).当地图位于前景中的选项卡时,一切似乎都没问题.但是当地图加载到背景选项卡中并且仅在单击选项卡后可见时,地图被错放/切断,当您尝试使用它时,它的功能似乎被破坏了.

我已经搜索了解决方案,我发现了这些技巧

google.maps.event.trigger(map, 'resize');
map.setCenter(center);
Run Code Online (Sandbox Code Playgroud)

但它不起作用.你能不能看看http://jsfiddle.net/n4q7Y/5/并告诉我我错过了什么?

谢谢.

javascript google-maps angularjs

6
推荐指数
1
解决办法
9022
查看次数

在Angular完成渲染后运行jQuery

我正在尝试使用angularjs中的json对象填充配置文件页面.我正在使用指令.我有一个profile指令,它有profile-section指令作为子节点.配置文件部分具有作为子项的配置文件子部分指令.我需要在角度开始编译之前和角度完成渲染模板之后运行一个片段.

我试过了

app.run()
$timeout
$evalAsync
$(document).ready()
$scope.$broadcast
postLink function
Run Code Online (Sandbox Code Playgroud)

这是我的代码的骨架

    var app = angular.module("profile",[]);

app.controller("profileController",['$scope',function($scope){
    var ctrl = this;


}])

.controller("profileSectionController",['$scope',function($scope){
    //$scope.$emit('dataloaded');

}])


.directive("profile",[function(){
    return {
        transclude:true,
        restrict:'EA',
        replace:true,
        templateUrl:'/sstatic/angular_templates/de/profile.html',
        scope:{
            person:"="
        },
        controller:'profileController',
        compile:function(elem,attrs,transclude){
            return {
                pre : function link(scope,elem,attrs,ctrl){
                    //angular.element(elem).find(".candidate-name").append(scope.person.name);
                //$(elem).css({"display":"none"});

                },
                post : function link(scope,elem,attrs,ctrl){
                    //angular.element(elem).find(".candidate-name").append(scope.person.name);
                    //$(elem).css({"display":"block"});



                }
            }
        }
    }
}])
.directive("profileSection",[function(){
    return {
        transclude:true,
        restrict:'EA',
        replace:true,
        require:'^profile',
        templateUrl:'/sstatic/angular_templates/de/profile-section.html',
        scope:{
            title:"@",
            right:"=",
            sub:"="
        },
        controller:"profileSectionController",
        compile:function(elem,attrs,transclude){
            return {
                pre : function link(scope,elem,attrs,ctrl){
                    //angular.element(elem).find(".candidate-name").append(scope.person.name);

                },
                post : …
Run Code Online (Sandbox Code Playgroud)

jquery angularjs

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

angularjs ×3

google-maps ×1

javascript ×1

jquery ×1

settimeout ×1