Ng-click无效 [英] Ng-click is not working
问题描述
Hi ,
When i load .cshtml pages in dialog-box(jQuery) then ng-click event is not working .<br />
without dialog-box working fine .
代码是:
Code is:
<li><a href="#" onclick="LoadDialogsBox('Account/Register', 'Register');">Register</a></li>
新用户注册
< label> UserName< / lab el>
< input type =textng-model =UserName/>
< label>电子邮件< / label>
< input type =textng-model =Email/>
< label>密码< / label>
< input type =textng-model =密码/>
< label> ConfirmPassword< / label>
< input type =textng-model =ConfirmPassword/>
< input type =buttonvalue =注册ng-click =AddRegistration()/>
Diallogbox的jquery代码。
New User Registration
<label>UserName</label>
<input type="text" ng-model="UserName" />
<label>Email</label>
<input type="text" ng-model="Email" />
<label>Password</label>
<input type="text" ng-model="Password" />
<label>ConfirmPassword</label>
<input type="text" ng-model="ConfirmPassword" />
<input type="button" value="Register" ng-click="AddRegistration()" />
jquery code for Diallogbox.
//jQueryUI method to create dialog box
function LoadDialogsBox(Url, Title) {
debugger;
A(Title);
$.ajax({
url: Url,
dataType: 'html',
async: true,
type: 'Get',
success: function (data) {
debugger;
$('#dialogbody').html(data);
$("#dialogbox").dialog("open");
},
error: function(er)
{
console.log(er);
} });
}
function A(Title) {
$(function () {
$("#dialogbox").dialog({
autoOpen: false,
width: 950,
height: 550,
title: Title,
draggable: true,
resizable: false,
});
});
}
Angular js Code.
var Accountapp = angular.module("MyApp", []);
Accountapp.controller("myctrl", function ($scope,$rootScope, myservice) {
$rootScope.AddRegistration = function () {
debugger;
var Registration = {
ULD_Email: $scope.Email,
ULD_Password: $scope.Password,
ULD_Name: $scope.UserName,
ULD_Profession:"N/A",
ULD_userType: "Normal",
ULD_Active:0,
ULD_Address:"N/A",
};
var getData = myservice.AddUser(Registration);
getData.then(function (msg) {
// GetAllEmployee();
alert(msg.data);
// $scope.divEmployee = false;
}, function () {
alert('Error in Registration record');
});
}
function ClearFields() {
$scope.UserName = "";
$scope.Password = "";
$scope.ConfirmPassword = ""
}
});
Accountapp.service("myservice", function ($http) {
// Add User First Registration
this.AddUser = function (Registration) {
debugger;
console.log(Registration);
try{
var response = $http({
method: "post",
url: "RegisterUser",
data: JSON.stringify(Registration),
dataType: "json",
// contentType: 'application/json; charset=utf-8',
});
}catch(e){alert(e.toString())}
return response;
}
}
);
Script call in layout
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/TrialsVision-jq.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
<script src="~/Ang_Script/Module/AccountModule.js"></script>
<script src="~/Ang_Script/Service/AccountService.js"></script>
<script src="~/Ang_Script/Controller/AccountController.js"></script>
我的尝试:
jquery对话框代码修改,angularjs链接更改,使用在线链接。等等
What I have tried:
jquery Dialog-box code modify , angularjs link change , use online link . etc.
推荐答案
.ajax({
url:url,
dataType:' html',
async: true ,
类型:' 获取',
成功:功能 (数据){
调试器;
.ajax({ url: Url, dataType: 'html', async: true, type: 'Get', success: function (data) { debugger;
(' #dialogbody')。html(data);
('#dialogbody').html(data);
( #dialogbox)。dialog( open );
},
错误:功能(呃)
{
< span class =code-sdkkeyword> console .log(er);
}});
}
功能 A(标题){
("#dialogbox").dialog("open"); }, error: function(er) { console.log(er); } }); } function A(Title) {
这篇关于Ng-click无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!