適切angularjsでfabric.jsを使用するには、もう少し勉強し、より多くの努力を入れています。 load fabric js in angular application
しかし、この特定の状況のために、私は解決策(回避策)
を持っているあなたのコードでこれらの変更を行います。
HTML
<input ng-model="user.firstName" ng-change="render()">
のJs
function LoginController($scope) {
$scope.user = {
firstName: "Foox",
lastName: "Bar"
};
// change-> "text":$scope.user.firstName
jsonobj ={"objects":[{"type":"textbox","originX":"left","originY":"top","left":100,"top":100,"width":220,"height":28.84,"fill":"rgb(0,0,0)","stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over",
"text":$scope.user.firstName,
"fontSize":22,"fontWeight":"normal","fontFamily":"Times New Roman","fontStyle":"","lineHeight":1.16,"textDecoration":"","textAlign":"center","textBackgroundColor":"","styles":{},"minWidth":20}],"background":"#fff"};
var canvas = window._canvas = new fabric.Canvas('c');
canvas.setBackgroundImage("" , canvas.renderAll.bind(canvas));
canvas.renderAll();
canvas.loadFromJSON(jsonobj, function(obj) {
canvas.renderAll();
});
$scope.render = function() {
jsonobj.objects[0].text = $scope.user.firstName;
canvas.loadFromJSON(jsonobj, function(obj) {
canvas.renderAll();
});
};
}
ここでそれが変更された値で再びキャンバスをレンダリングし、何が起こるかです。
jsfiddleリンク:https://jsfiddle.net/harshakj89/La00wahb/
完全に動作します。ありがとう@Durga – ASD