2016-03-07 65 views
1

我有一个表单,使用Material Design Lite呈现,我通过回调异步REST API调用来填充,但我在DOM中获得以下结果:异步填充后材质设计精简版表单不会呈现

enter image description here

如果我专注于一个文本框,它通常显示,因为不是如果我不(标题必须是在文本上)。当我查看HTML时,我看到value属性没有显示,这可能是为什么。我填充字段是这样的:

$.ajax({ 
    url: '/api/v1/map/config', 
    method: 'get', 
    success: function(response) { 
     this.xoffset = response.xoffset; 
     this.yoffset = response.yoffset; 
     this.xscaling = response.xscaling; 
     this.yscaling = response.yscaling; 
     this.path = response.path; 

     $("input[name=xoffset]").val(response.xoffset); 
     $("input[name=yoffset]").val(response.yoffset); 
     $("input[name=xscaling]").val(response.xscaling); 
     $("input[name=yscaling]").val(response.yscaling); 
     $(".map-preview").html("<img src='" + response.path + "' />"); 
     componentHandler.upgradeAllRegistered(); 
    }, 
    error: function(err) { 
     err = JSON.parse(err.responseText); 
     if (err.error) { 
      SnackbarManager.pushError(err.error); 
     } else { 
      SnackbarManager.pushError("Une erreur s'est produite"); 
     } 
    } 
}); 

谢谢您的帮助

+0

试试这个回答: http://stackoverflow.com/questions/31638890/mdl-textfield-not-taking-ngmodel-changes-into-account/40781433#40781433 – Mao

回答

1

试试这个代码...在我的应用程序,我曾与田动力,把后的HTML的一个问题..

angular.module('app', ['ngRoute']). 

run(function($rootScope, xxxx, xxx){ 
    $rootScope.$on('$viewContentLoaded', function(event, next) { 
     componentHandler.upgradeAllRegistered(); 
    }); 
});