I have a button on clicking which a popup is opened, addRow function is called to add a row. This row has a button on clicking which new rows can be added. However when i click on this, no function is called and nothing happens. Please help.
<body ng-app="myApp" ng-controller="myCtrl">
<div id="sample"><!-- onload="init()">-->
<h3>Make your own Flowchart</h3>
<button ng-click = "addSystem()" type="submit" id="btn-save">Add System</button>
Within my controller code starts as follows.
<script type="text/javascript">
var app=angular.module('myApp',[]);
app.controller('myCtrl', function($scope)
{
$scope.sysInfo=[];
later i have addSystem function is as follows:
$scope.addSystem=function()
{
console.log("Inside add system");
var str="<form><table id=\"sysTab\"></table></form>";
console.log("str is "+str);
$(str).dialog({
modal: true,
title:"Add system info",
height:"auto",
width:"auto",
buttons: {
'OK': function () {
//console.log($('#sysName'));
init();
$( this ).dialog( "close" );
},
'Cancel': function () {
$(this).dialog('close');
}
}
});
$scope.addRow();
}
$scope.addRow=function()
{
$scope.index=$scope.index+1;
console.log("index is "+$scope.index);
console.log("Inside add row");
$('#sysTab').append("<tr><td>System Name : </td><td><input rowid=\""+$scope.index+"\"type=\"text\" id=\"sysName"+$scope.index+"\"/></td><td><input type=\"text\" class=\"basic"+$scope.index+"\"/></td><td><input type=\"button\" value=\"+\" ng-click=\"addRow("+$scope.index+")\" title=\"Add new system info\"/></td><td><input type=\"button\" value=\"-\" onclick=\"deleteRow(this)\" title=\"Delete system info\"/><p id=\""+$scope.index+"\" style=\"display:none;\"></p></td></tr>");
console.log("row added");
$(".basic"+$scope.index).spectrum({
color: "#f00",
change: function(color) {
console.log("Inside change");
console.log($('#sysName'+$(this).closest('tr').index()).val());
sysInfo.push({"index":$(this).closest('tr').index(), "name": $('#sysName'+$(this).closest('tr').index()).val(), "color":color.toHexString()});
console.log(sysInfo);
}
});
}
i tried calling as $scope.addRow() but i am getting no response. i tried a lot without any success. Any pointers will be greatly helpful.
未定义$ scope的问题通过将范围显式调用为angular.element(document.getElementByID('master div element here')。scope()来解决
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.