2017-04-18 30 views
3

語境與角調用HREF開模

I'm在此Tutorial工作,即將與DataTable的CRUD,但使用Asp.Net的WebAPI與角

I'm差異I'm到步驟9,在那裏由教程爲彈出窗口的局部視圖,但我不使用局部視圖,而是,我使用角視圖

問題

我不知道如何更換我的角度認爲,部分觀點

代碼

查看

<table class="table table-striped table-hover table-bordered dt-bootstrap no-footer" id="tabla_catalogos" role="grid" aria-describedby="sample_editable_1_info"> 
    <thead> 
    <tr> 
     <th class="hidden"></th> 
     <th style="width: 200px;"> Codigo </th> 
     <th> Nombre </th> 
    </tr> 
    </thead> 
    <tbody></tbody> 
</table> 

JS

$('#tabla_catalogos') 
     .DataTable({ 
      searching: true, 
      dom: 'ftpB', 
      autoWidth: false, 
      buttons: [ 
       //'excelHtml5', 'csv', 'print' 
      ], 
      paging: true, 
      select: { 
       style: 'single' 
      }, 
      info: false, 
      ordering: true, 
      "processing": true, 
      ajax: { 
       method: 'GET', 
       url: "../../api/Catalogo/GetCatalogoRegistro/" + selected.ID, 
       dataSrc: '', 
       beforeSend: function(request) { 
        request.setRequestHeader("Version", $scope.usuario.Version); 
        request.setRequestHeader("Origen", 'Web'); 
       } 
      }, 
      columns: [ 
      { data: 'Catalogo', visible: false, searchable: false }, 
      { data: 'Codigo' }, 
      { data: 'ID', visible: false, searchable: false }, 
      { data: 'Nombre' }, 
      { data: 'Padre', visible: false, searchable: false }, 
      { 
       data: 'ID', 
       render: function(data){ 
        return '<a class="popup" href="root.detalleregistros'+data+'">Editar</a>'; 
       } 
      }, 
      { 
       data: 'ID', 
       render: function (data) { 
        return '<a class="popup" href="root.detalleregistros' + data + '">Eliminar</a>'; 
       } 
      } 

      ], 
      pageLength: 10 //, 
      //pagingType: "simple_numbers" 
      , 
      language: { 
       "emptyTable": "No se encontraron registros", 
       "zeroRecords": "No encontraron coincidencias", 
       "search": "Buscar: " 
      } 
     }); 

    $('.tablecontainer').on('click', 'a.popup', function (e) { 
     e.preventDefault(); 
     OpenPopup($(this).attr('href')); 
    }); 

    function OpenPopup(pageUrl) { 
     var $pageContent = $('<div/>'); 
     $pageContent.load(pageUrl, function() { 
      $('#popupForm', $pageContent).removeData('validator'); 
      $('#popupForm', $pageContent).removeData('unobtrusiveValidation'); 
      $.validator.unobtrusive.parse('form'); 

     }); 

     $dialog = $('<div class="popupWindow" style="overflow:auto"></div>') 
        .html($pageContent) 
        .dialog({ 
         draggable: false, 
         autoOpen: false, 
         resizable: false, 
         model: true, 
         title: 'Popup Dialog', 
         height: 550, 
         width: 600, 
         close: function() { 
          $dialog.dialog('destroy').remove(); 
         } 
        }) 

     $('.popupWindow').on('submit', '#popupForm', function (e) { 
      var url = $('#popupForm')[0].action; 
      $.ajax({ 
       type: "POST", 
       url: url, 
       data: $('#popupForm').serialize(), 
       success: function (data) { 
        if (data.status) { 
         $dialog.dialog('close'); 
         oTable.ajax.reload(); 
        } 
       } 
      }) 

      e.preventDefault(); 
     }) 
     $dialog.dialog('open'); 
    } 

}; 

角服務,調用視圖:

.state('root.detalleregistros', { 
       url: "detalleRegistros.html", 
       templateUrl: "../SPA/administrador/catalogos/detalleRegistros.html", 
       controller: "detalleRegistrosCtrl", 
       authenticate: true 
      }) 

當我CLIC到網址爲MI碼'<a class="popup" href="root.detalleregistros'+data+'">Editar</a>';它重定向我http://localhost:55720/admin/root.detalleregistros/1

代替

http://localhost:55718/admin/#/detalleRegistros.html

我'在那裏做錯了嗎?非常感謝幫助。問候

我嘗試'<a class="popup" ui-sref="root.detalleregistros({data:11})">Editar</a>';作爲@Agam Banga的評論,但模態只是不打開,我需要添加一些表視圖?或者那裏可能是錯的?

+0

大@josep :)請不要張貼同樣的問題兩次,更好,更新原來的文章作出澄清或闡述。 – davidkonrad

+0

是的,我更新這一個,並刪除其他帖子@davidkonrad – Josep

回答

0

您已經定義了「root.detalleregistros」的狀態。要打開這個狀態,你需要使用ui-sref的ui-router的inbuild指令。

<a ui-sref="root.detalleregistros">Editar</a> 

另外,如果你想傳遞參數,可以可以使用

<a ui-sref="root.detalleregistros({data:11})">Editar</a> 
+0

我這樣做,但我的模態不打開,沒有錯誤確定控制檯,只是不打開 – Josep

+0

你在那裏兄弟? – Josep