AngularJS - View Controller and Filter Controller
Date : March 29 2020, 07:55 AM
it fixes the issue That small demo should hepls you http://jsbin.com/duzaxa/1/edit?html,js,output<body ng-app="app">
<div ng-controller="filterController">
<input type="text" ng-model="myfitler.$"/>
</div>
<div ng-controller="tableController">
<table>
<tr ng-repeat="data in DataArray|filter:myfitler.$">
<td>{{data.field1}}</td>
<td>{{data.field2}}</td>
<td>{{data.field3}}</td>
</tr>
var app = angular.module('app', []);
app.factory("filterService", function(){
var _filter = {}
{
return {
filter:_filter
}
}
})
app.controller("filterController", function($scope, filterService){
$scope.myfitler = filterService.filter
})
app.controller('tableController', function($scope, filterService){
$scope.myfitler = filterService.filter
$scope.DataArray =
[
{field1:1,field2:"mike",field3:"student"},
{field1:2,field2:"john",field3:"techer"},
{field1:3,field2:"tim",field3:"studend"},
{field1:4,field2:"jessie",field3:"studend"}
]
});
|
angularJs filter from in controller
Date : March 29 2020, 07:55 AM
Any of those help Well if you want to filter by name and id from within the controller you could just use native filter. Look at the polyfill for support for older browsers. var type = "TypeTOfilter", id=idToFilter;
$scope.items = items.filter(function(itm){ return itm.id === id && itm.type === type });
.controller('ctrl', ['$scope', 'filterFilter', function($scope, filter){
//...
$scope.items = filter(items)({type:type, id:id});
//....
}]);
|
Determine Angularjs Controller based on route params
Date : March 29 2020, 07:55 AM
it should still fix some issue The controller function is not a function returning the controller name. It's supposed to be the controller itself. Let's suppose the tree route param can be Foo or Bar, you just need .when('/:section/Foo', {
templateUrl: function($routeParams) { return 'App/Views/'+$routeParams.section+'/Foo.html'; },
controller: 'FooController'
})
.when('/:section/Bar', {
templateUrl: function($routeParams) { return 'App/Views/'+$routeParams.section+'/Bar.html'; },
controller: 'BarController'
})
['Foo', 'Bar', 'Baz', 'Brr', ...].forEach(function(tree) {
$routeProvider.when('/:section/' + tree, {
templateUrl: function($routeParams) { return 'App/Views/' + $routeParams.section+'/' + tree + '.html'; },
controller: tree + 'Controller'
});
});
|
AngularJs Performance of Filter vs Filter inside Controller
Date : March 29 2020, 07:55 AM
|
Angularjs filter in controller. How to filter not null, undefined and false values?
Date : March 29 2020, 07:55 AM
|