我有角组件,并向名称为testservices
的构造函数中注入了服务,该构造函数的名称为id
。
可以在jquery click函数中使用testservice
并将值赋给id属性吗?
(请注意,我不想使用角度点击,因为我使用了无法实现角度点击的jquery
组件)
一些代码:
export class InboxComponent implements OnInit,AfterViewInit {
private initDatatable(): void {
var LessonDt;
var ExamDt;
var dtLes;
var folId = "";
$(".btnAddAcceptPlaceId").click(function () {
$(".lsnMng").show();
});
$(".sidebar-inner").on('click', 'li.folders', function () {
folId = $(this).attr("data-target");
LessonDt.refresh();
});
LessonDt = {
dtLes: null,
init: function () {
// alert('sasasa3');
// charset=utf-8
dtLes = $('#Inbox-data-table').DataTable({
// "createdRow": function ( row, data, index ) {
// const self = this;
// jQuery('td', row).unbind('click');
// jQuery('td', row).bind('click', () => {
// rowClickHandler(data)
// });
// console.log(data["docSubject"]);
// return row;
// },
"dom": 'Bfrtip',
"serverSide": true,
"processing": true,
"stateSave": true,
"autoWidth": false,
"paging": true,
"searching": false,
"ajax": {
"url": "http://localhost/WCFMobile/Document.svc/GetShowInboxAngular",
"type": "POST",
"contentType": "application/json; charset=utf-8",
// dataType: 'application/json; charset=utf-8',
// "data": '{"input":' + JSON.stringify({
// WsUserName: "MobRest95Q!@",
// WsPassword: "M0brE$T@u0m@ti0n95!!",
// folId : "7ca19498-3d67-4b3a-82e4-c8c57b73f07f",
// prsOrganizationId : "",
// PrsId : "",
// OrgCode:250
// }) + '}',
"data":
function (d) {
d.folId = "7ca19498-3d67-4b3a-82e4-c8c57b73f07f",
d.OrgCode = "250",
d.prsOrganizationId = "",
d.PrsId = ""
return JSON.stringify(d)
},
error: function (xhr, status, error) {
// alert('error');
console.log(xhr.responseText);
},
// "data": function (data) {
// data.FacilitySite = $("#FacilitySite").val();
// data.Building = $("#Building").val();
// data.Manufacturer = $("#Manufacturer").val();
// data.Status = $("#Status").val();
// }
},
"order": [[3, "desc"]],
"columns": [
{
"title": "موضوع",
width: '30%',
"data": "docSubject",
"contentType": "application/json; charset=utf-8",
"searchable": false,
"sortable": true,
"render": function (data, type, full, meta) {
return '<div id="divclick" onclick="showMsg()">test</div>';
}
},
],
"oLanguage": {
"sUrl": "/Content/dataTables.persian.txt",
"order": [[6, "desc"]]
},
"lengthMenu": [[10, 20, 30, 100], [10, 20, 30, 100]],
});
var table = $('#Inbox-data-table').DataTable();
},
refresh: function () {
dtLes.ajax.reload();
var table = $('#Inbox-data-table').DataTable();
}
}
$('#Inbox-data-table').on('click', 'tr,.editQuestion,.DelQuestion,.AddQuestion,.CorrectExam,.link', function () {
var arr = $('#Inbox-data-table').dataTable().fnGetData($(this).closest("tr"));
var row = $(this).closest("tr");
if (arr != null && $(this).attr("class") == "link") {
return true;
}
****************************************
this.router.navigateByUrl('/login'); // in this line i want to use typescript router
*********************************************
}
});
LessonDt.init();
}
constructor(private route: ActivatedRoute,
private router: Router) {
ngOnInit() {
this.route.params.subscribe(
data =>
{
this.folId = data["p1"];
this.orgCode = data["p2"];
this.folName = data["p3"];
this.orgId = data["p4"];
console.log(this.folId);
}
)
}
}