这是我的Html和JavaScript代码,我想通过函数更改它.
HTML:
JavaScript的:
function item(id,name) {
this.id = id;
this.name = name;
};
angular.module('myApp',[]).controller('myController',function($scope) {
$scope.items = [];
$scope.makeVisible = "";
$scope.initItems = function() {
$scope.items.push(new item("0",'Vikash'));
$scope.items.push(new item("1",'Kumar'));
$scope.items.push(new item("2",'Vishal'));
$scope.items.push(new item("3",'Ajay'));
};
$scope.renameThis = function(index,oldValue) {
console.log("oldValue==" + oldValue);
console.log("indexx==" + index);
var id = 'Box-' + index;
console.log("Id : " + id);
document.getElementById(id).style.display = "block";
console.log('jai hind');
};
$scope.showme = function(id) {
$scope.makeVisible = id;
console.log('id',id);
};
$scope.hideme = function(id) {
console.log(item);
$scope.makeVisible = "";
};
$scope.title = 'Enter new name here';
$scope.rename = function() {
$scope.item.name = $scope.newname;
console.log('dfasdd');
};
});
这是ng-init中的值,它在输入框1中显示,我想在点击时用第二个输入框的值更改它.我怎样才能做到这一点?
我还在按钮上添加了一个功能.
最佳答案