如何将ng-model作为参数传递给ng-mousedown [英] How to pass ng-model as parameter to ng-mousedown
问题描述
我在此页面上有html页面我想将ng-model的值作为参数传递给ng-mousedown: -
< ng-model ng-mousedown =check(ctrl .selectedPeople)>
我有一个关于html文件的js文件,我在这个文件中写了角度代码我有一个CHECK(searchtext)函数,我想在mousedown事件上调用它,但是我将searchtext参数设置为undefined,
i have html page on this page i want to pass the value of ng-model as a parameter to ng-mousedown :-
<ng-model ng-mousedown="check(ctrl.selectedPeople)">
And i have an js file with respect to html file where i write angular code in this file i have a function that is CHECK(searchtext) , i want to call it on mousedown event but i getting searchtext parameter as undefined ,
/// <reference path="library/angular.js" />
'use strict';
var app = angular.module('demo', ['ngSanitize', 'ui.select']);
app.filter('propsFilter', function () {
return function (items, props) {
var out = [];
if (angular.isArray(items)) {
var keys = Object.keys(props);
items.forEach(function (item) {
var itemMatches = false;
//itemMatches = true;// when data will populate from database.
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
// itemMatches = false;
itemMatches = true;// when data will populate from database.
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
out = items;
}
return out;
};
});
app.controller('DemoCtrl', function ($scope) {
var result = this;
result.tagTransform = function (newTag) {
var item = {
name: newTag
};
return item;
};
//var str = "January,February,March,April,May,June,July,August,September,October singh";
//var splittedString = str.split(',');
var arr = [];
//splittedString.forEach(function (v) {
// arr.push({ name: v });
//});
var arr = [
{
"name": "TCS",
"Access": "TATA"
},
{
"name": "GG",
"Access": "GOOGLE"
},
{
"name": "MS",
"Access": "Micosoft"
}
];
result.people = arr;
result.colors = ['Blue', 'Red'];
result.selectedPeople2 = result.selectedPeople;
$scope.check = function (searchText) {
debugger;
var Forsecond="";
var ff = searchText[0];
var dd = ff.name;
if(dd==ff.name)
{
Forsecond= ff.Access;
}
return Forsecond;
}
});
我尝试过:
i在此页面上有html页面我想将ng-model的值作为参数传递给ng-mousedown: -
< ng-model ng-mousedown =check(ctrl.selectedPeople)>
我有一个js文件尊重html文件,我在这个文件中写角度代码我有一个CHECK(searchtext)函数,我想在mousedown事件上调用它,但我得到searchtext参数为undefined,
What I have tried:
i have html page on this page i want to pass the value of ng-model as a parameter to ng-mousedown :-
<ng-model ng-mousedown="check(ctrl.selectedPeople)">
And i have an js file with respect to html file where i write angular code in this file i have a function that is CHECK(searchtext) , i want to call it on mousedown event but i getting searchtext parameter as undefined ,
/// <reference path="library/angular.js" />
'use strict';
var app = angular.module('demo', ['ngSanitize', 'ui.select']);
app.filter('propsFilter', function () {
return function (items, props) {
var out = [];
if (angular.isArray(items)) {
var keys = Object.keys(props);
items.forEach(function (item) {
var itemMatches = false;
//itemMatches = true;// when data will populate from database.
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
// itemMatches = false;
itemMatches = true;// when data will populate from database.
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
out = items;
}
return out;
};
});
app.controller('DemoCtrl', function ($scope) {
var result = this;
result.tagTransform = function (newTag) {
var item = {
name: newTag
};
return item;
};
//var str = "January,February,March,April,May,June,July,August,September,October singh";
//var splittedString = str.split(',');
var arr = [];
//splittedString.forEach(function (v) {
// arr.push({ name: v });
//});
var arr = [
{
"name": "TCS",
"Access": "TATA"
},
{
"name": "GG",
"Access": "GOOGLE"
},
{
"name": "MS",
"Access": "Micosoft"
}
];
result.people = arr;
result.colors = ['Blue', 'Red'];
result.selectedPeople2 = result.selectedPeople;
$scope.check = function (searchText) {
debugger;
var Forsecond="";
var ff = searchText[0];
var dd = ff.name;
if(dd==ff.name)
{
Forsecond= ff.Access;
}
return Forsecond;
}
});
推荐答案
范围){
var result = this ;
result.tagTransform = function (newTag){
var item = {
name:newTag
};
return 项目;
};
// var str =1月,2月,3月,4月,5月,6月,7月,8月,九月,十月辛格;
// var splittedString = str.split(',' );
var arr = [];
// splittedString.forEach(function(v){
// arr.push({name:v});
// });
var arr = [
{
name: TCS,
访问: TATA
},
{
name: GG,
<温泉n class =code-string>访问: GOOGLE
},
{
name : MS,
访问: Micosoft
}
];
result.people = arr;
result.colors = [' Blue',' Red'];
result.selectedPeople2 = result.selectedPeople;
scope) { var result = this; result.tagTransform = function (newTag) { var item = { name: newTag }; return item; }; //var str = "January,February,March,April,May,June,July,August,September,October singh"; //var splittedString = str.split(','); var arr = []; //splittedString.forEach(function (v) { // arr.push({ name: v }); //}); var arr = [ { "name": "TCS", "Access": "TATA" }, { "name": "GG", "Access": "GOOGLE" }, { "name": "MS", "Access": "Micosoft" } ]; result.people = arr; result.colors = ['Blue', 'Red']; result.selectedPeople2 = result.selectedPeople;
scope.check = function (searchText){
调试器;
var Forsecond = ;
var ff = searchText [ 0 ];
var dd = ff.name;
if (dd == ff.name)
{
Forsecond = ff.Access;
}
返回 Forsecond;
}
});
scope.check = function (searchText) { debugger; var Forsecond=""; var ff = searchText[0]; var dd = ff.name; if(dd==ff.name) { Forsecond= ff.Access; } return Forsecond; } });
我尝试过:
i在此页面上有html页面我想将ng-model的值作为参数传递给ng-mousedown: -
< ng-model ng-mousedown =check(ctrl.selectedPeople)>
我有一个js文件尊重html文件,我在这个文件中写角度代码我有一个CHECK(searchtext)函数,我想在mousedown事件上调用它,但我得到searchtext参数为undefined,
What I have tried:
i have html page on this page i want to pass the value of ng-model as a parameter to ng-mousedown :-
<ng-model ng-mousedown="check(ctrl.selectedPeople)">
And i have an js file with respect to html file where i write angular code in this file i have a function that is CHECK(searchtext) , i want to call it on mousedown event but i getting searchtext parameter as undefined ,
/// <reference path="library/angular.js" />
'use strict';
var app = angular.module('demo', ['ngSanitize', 'ui.select']);
app.filter('propsFilter', function () {
return function (items, props) {
var out = [];
if (angular.isArray(items)) {
var keys = Object.keys(props);
items.forEach(function (item) {
var itemMatches = false;
//itemMatches = true;// when data will populate from database.
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
// itemMatches = false;
itemMatches = true;// when data will populate from database.
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
out = items;
}
return out;
};
});
app.controller('DemoCtrl', function (
scope){
var result = < span class =code-keyword> this ;
result.tagTransform = function (newTag){
var item = {
name:newTag
};
返回项;
};
// var str =1月,2月,3月,4月,5月,6月,7月,8月,9月,10月辛格;
// var splittedString = str.split(',');
var arr = [];
// splittedStr ing.forEach(function(v){
// arr.push({name: v});
// });
var arr = [
{
< span class =code-string> name: TCS,
访问: < span class =code-string> TATA
},
{
name: GG,
访问: GOOGLE
},
{
name: MS,
访问: Micosoft
}
];
result.people = arr;
result.colors = [' Blue',' Red'];
result.selectedPeople2 = result.selectedPeople;
scope) { var result = this; result.tagTransform = function (newTag) { var item = { name: newTag }; return item; }; //var str = "January,February,March,April,May,June,July,August,September,October singh"; //var splittedString = str.split(','); var arr = []; //splittedString.forEach(function (v) { // arr.push({ name: v }); //}); var arr = [ { "name": "TCS", "Access": "TATA" }, { "name": "GG", "Access": "GOOGLE" }, { "name": "MS", "Access": "Micosoft" } ]; result.people = arr; result.colors = ['Blue', 'Red']; result.selectedPeople2 = result.selectedPeople;
这篇关于如何将ng-model作为参数传递给ng-mousedown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!