2016-03-07 51 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(); 
    }); 
}); 
相關問題