Вызов угловой функции с помощью Jquery
Как вызвать угловую функцию, когда данные в текстовом поле? вот мой код
HTML
From
RGN
NYU
MDl
HEH
To
RGN
NYU
MDl
HEH
JS
function buildPaths(route){
var points = route.split(">");
var paths = {};
for(var i = 0; i < points.length; i++){
var from = points[i];
for(var j = i; j < points.length; j++){
var to = points[j];
if (from != to){
if(paths[from + ">" + to]){
if(j-i < paths[from + ">" + to][0])
paths[from + ">" + to] = [j-i,points.slice(i,j+1).join(">")]
}else{
paths[from + ">" + to] = [j-i,points.slice(i,j+1).join(">")]
}
}
}//for j
}//for i
return paths;
}
var flightSearch = angular.module('flightSearch',['ngSanitize']);
flightSearch.controller('flightSearchController', function ($scope){
// Data definitions, route is actual data,
// display route is for higlight display purpose only.
var dataRoutes = [
{route: "RGN>NYU>MDL>HEH>RGN", displayRoute: "", paths: []},
{route: "RGN>HEH>KYT>THK>KYT>HEH>RGN", displayRoute: "", paths: []},
{route: "RGN>MDL>HEH>NYU>RGN", displayRoute: "", paths: []},
{route: "RGN>MDL>STW>RGN", displayRoute: "", paths: []},
{route: "RGN>NYU>MDL>MYT>PTO>MYT>MDL>NYU>RGN", displayRoute: "", paths: []},
{route: "RGN>HEH>NYU>MDL>RGN", displayRoute: "", paths: []},
{route: "RGN>TVY>MGU>KAW>MGU>TVY>RGN", displayRoute: "", paths: []},
{route: "RGN>TVY>KAW>TVY>RGN", displayRoute: "", paths: []},
{route: "RGN>KAW>MGU>TVY>RGN", displayRoute: "", paths: []}];
// Pre-calculate the possible path the shortest distance
for(var r = 0; r< dataRoutes.length; r++){
dataRoutes[r]["paths"] = buildPaths(dataRoutes[r]["route"]);
dataRoutes[r]["displayRoute"] = dataRoutes[r]["route"];
}
// Assign the routes. This is unfiltered origintal data (all)
$scope.routes = dataRoutes;
// This is filtered list for dispaly
$scope.filteredItems = $scope.routes;
// Search/filter function. This updates filteredItems list
$scope.flightSearch = function(){
if($scope.query.length > 6){
$scope.filteredItems = [];
for(var index in $scope.routes){
$scope.routes[index]["displayRoute"] = $scope.routes[index]["route"];
if($scope.routes[index]["paths"][$scope.query] !== undefined){
var match = $scope.routes[index]["paths"][$scope.query][1];$scope.query
$scope.routes[index]["displayRoute"] = $scope.routes[index]["route"].replace(match,"" + match + "");
$scope.filteredItems.push($scope.routes[index]);
}
}
}else{
for(var r = 0; r< $scope.routes.length; r++){
$scope.routes[r]["displayRoute"] = $scope.routes[r]["route"];
}
$scope.filteredItems = $scope.routes;
}
}
});
flightSearch.filter("highlight",function(){
return function(text){
return text;
}
});
$(function() {
$("#options").change(function(){
setTarget()
});
$("#options2").change(function(){
setTarget();
});
$("#options3").change(function(){
setTarget();
});
$("#targetTextField").change(function(){
setTarget();
});
});
function setTarget(){
var tmp = $("#options").val();
tmp += $("#options2").val();
tmp += $("#options3").val();
$('#targetTextField').val(tmp);
}
когда два варианта выбора вставить данные в текстовое поле хотят вызвать функцию поиска по тексту change.strong