Forms 材料设计Lite表单赢得';异步填充后不进行渲染

Forms 材料设计Lite表单赢得';异步填充后不进行渲染,forms,asynchronous,data-binding,material-design,Forms,Asynchronous,Data Binding,Material Design,我有一个用Material Design Lite呈现的表单,由于回调了一个异步REST Api调用,我填充了该表单,但我在DOM中得到了以下结果: 如果我关注文本字段,它会正常显示,因为如果我不关注,则不会显示(标题必须在文本上方)。当我查看HTML时,我看到值属性没有显示,这就是原因。我以这种方式填充字段: $.ajax({ url: '/api/v1/map/config', method: 'get', success: function(response) {

我有一个用Material Design Lite呈现的表单,由于回调了一个异步REST Api调用,我填充了该表单,但我在DOM中得到了以下结果:

如果我关注文本字段,它会正常显示,因为如果我不关注,则不会显示(标题必须在文本上方)。当我查看HTML时,我看到
属性没有显示,这就是原因。我以这种方式填充字段:

$.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");
        }
    }
});
$.ajax({
url:“/api/v1/map/config”,
方法:“get”,
成功:功能(响应){
this.xoffset=response.xoffset;
this.yoffset=response.yoffset;
this.xscaling=response.xscaling;
this.yscaling=response.yscaling;
this.path=response.path;
$(“输入[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(“”);
componentHandler.upgradeAllRegistered();
},
错误:函数(err){
err=JSON.parse(err.responseText);
if(err.error){
SnackbarManager.pushError(err.error);
}否则{
SnackbarManager.pushError(“Une erreur s'est produite”);
}
}
});

感谢您的帮助

请尝试此代码。。。在我的应用程序中,在放入html后,我遇到了字段动态的问题

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

run(function($rootScope, xxxx, xxx){
    $rootScope.$on('$viewContentLoaded', function(event, next) {
        componentHandler.upgradeAllRegistered();
    });
});
试试这个答案: