Hi,
I have a live search that's getting data from a factory. How do I build
the functionality to select something in the list and populate a new view
with the associated data. The name, job, and vehicle # need to populate on
a new view. Where do I begin?
<table width="224" align="center" ng-show="(filteredData =
(vehicleSearch.sample | filter:search)) && search && search.length >= 2">
<tr ng-repeat="person in filteredData">
<td width="112" align="left">{{person.name}}</td>
<td width="119" align="left">{{" #" + person.vehicle}}</td>
</tr>
</table>
// ROUTING
myApp.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'pages/main.html',
controller: 'mainController'
})
.when('/second', {
templateUrl: 'pages/second.html',
controller: 'secondController'
})
});
// CONTROLLER: FIND A VEHICLE
myApp.controller('mainController', function($scope, truckData) {
$scope.vehicleSearch = truckData;
});
// CONTROLLER
myApp.controller('secondController', ['$scope', function($scope) {
$scope.name = 'Second';
}]);
// FACTORY
myApp.factory('truckData', function () {
var truckData = {};
truckData.drivers = [
{
name: "John Doe",
job: "Designer",
vehicle: "1234"
},
{
name: "Jake Doe",
job: "Developer",
vehicle: "5678"
},
{
name:"Jane Doe",
job: "DUX Lead",
vehicle:"9012"
}
];
return truckData;
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.