2016-09-02 5 views
0

こんにちは、私はAngel MaterialからmdDialogを表示し、ディレクティブコントローラをダイアログのコントローラとして使用しているので、stuffを返さずに特定の関数を呼び出すことができます。余分な手順をコードに追加します。関数は正常に呼び出されますが、関数が正常に終了するとUIは更新されません。誰かがこれでどこが間違っているのか分かりますか?mdDialogが親コントローラの関数を呼び出すときにUIが更新されない

最初のif文が真であると仮定します。

ダイアログ関数が呼び出されている

this.showImageUploadModal = function() { 
    $mdDialog.show({ 
     clickOutsideToClose: true, 
     scope: $scope,  // use parent scope in template 
     preserveScope: true, // do not forget this if use parent scope 
     templateUrl: 'app/directives/modals/upload-files-modal.html', 
     controller: MessagingController, 
     controllerAs: 'controller' 
     }); 
}; 

コールが、更新していない私は私がAngulars $ rootScopeを使用して探していたものを達成できた最終的にはUI

this.addAttachment = function() { 
    console.log("sending attachment"); 
    var ref = this; 
    var note = this.user.first_name + " has attached a file."; 

    if($state.current.name === 'inbox') { 
    MessagingService.createMessage(this.convo.id, note, this.userUploadedNoteFiles).then(
     function success(response) { 
     console.log("Inbox attachment sent", response); 
     ref.convo.messages.push(response.data); 
     console.log(ref.convo.messages); 
     // ref.viewableNoteFiles = []; 
     }, 
     function failure(response) { 
     $mdToast.show(
      $mdToast.simple(). 
      textContent("Failed to send the message please try again."). 
      theme('error-toast')); 
     } 
    ); 
    } else if (this.notes === 'true') { 
    TicketingService.addNote($stateParams.id, note, this.userUploadedNoteFiles).then(
     function success(response) { 
     console.log("Notes attachment sent", response); 
     ref.convo.messages.push(response.data); 
     // ref.viewableNoteFiles = []; 
     }, 
     function failure(response) { 
     $mdToast.show(
      $mdToast.simple(). 
      textContent("Failed to send the message please try again."). 
      theme('error-toast')); 
     } 
    ); 
    } else if(this.contractor === 'true') { 
    TicketingService.createMessage($stateParams.id, this.convo.id, note, this.userUploadedNoteFiles).then(
    function success (response) { 
     console.log("Contractor attachment sent", response); 
     ref.convo.messages.push(response.data); 
    }, 
    function failure() { 
     $mdToast.show(
     $mdToast.simple(). 
     textContent("Failed to upload the file attachments"). 
     theme('error-toast')); 
    } 
); 
    } 

}; 

答えて

0

。$放送。戻りデータを必要なコントローラに戻してブロードキャストします。

これは正しい方法ですが、うまくいきますが、それは機能します。

関連する問題