2017-04-07 25 views
0

我有下面的代碼片段。使用javascript更改角形formly模板html

page.fields[{ 
template: '<div><img ng-click="exportCSV();"src="../Login/images/excel_icon.jpg" title="Export CSV"/></div>', 
controller: ['$scope', function (scope) {         
     scope.exportCSV = function() {          
     var __this = this; 
     this.fields[0].template = '<div>hello</div>'; 
     this.fields[0] = angular.copy(this.fields[0]); 

執行某些操作後,我想更改此功能中的模板html。

function cb(status) { 
    __this.fields[0].template = '<div>hello Ankur</div>'; 
    __this.fields[0] = angular.copy(__this.fields[3]); 

}] 

沒有設置新的模板值,但是當我執行任何動作頁,然後它反映在模板中的變化。請提出解決方案。

回答

0

我不太瞭解。但是,這2個字符串看起來像錯誤的順序

__this.fields[0].template = '<div>hello jiiii</div>'; 
__this.fields[0] = angular.copy(__this.fields[3]); 
+0

其實它是角形形式控制,其中我使用模板來顯示下載Excel圖像。當點擊該圖像時,需要一段時間,我只隱藏Excel圖像並在下載完成後顯示其他圖像,然後顯示excel圖像。問題是excel圖像在下載文件後沒有顯示,但是當點擊頁面時顯示。 –