w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Angularjs ng-repeat custom filter breaks orderBy filter?
You are currently exposing an object to orderBy, this should probably be an array. Try replacing return tags; at the end of your uniqueTickers filter with the following: var arr = []; for (var ticker in tags) { arr.push(tags[ticker]); } return arr;

Categories : Javascript

AngularJS multiple filter with custom filter function
Try this: <tr ng-repeat="player in players | filter:{id: player_id, name:player_name} | filter:ageFilter"> $scope.ageFilter = function (player) { return (player.age > $scope.min_age && player.age < $scope.max_age); }

Categories : Javascript

Can only one error / success function be assigned for AngularJS $http promises?
If you do : $http.get('..').error(someFunc).error(someFunc2); someFunc2 will only fire if someFunc throws an error. This is in line with the code snippet that Jonathan Lonowski pointed out : https://github.com/angular/angular.js/blob/v1.1.5/src/ng/http.js#L714-L719 If you want to run multiple functions you can do: $http.get('..').error(function () {someFunc();someFunc2();});

Categories : Javascript

UIPageViewController: get the currentPage
It looks like you should be able to get the current index with: ContentViewController *viewController = [self.pageViewController.viewControllers lastObject]; currentIndex = [modelArray indexOfObject:[viewController page]];

Categories : Iphone

Howto read currentpage after index.php?
You can retrieve the anchor fragment (everything after #) by using parse_url(); see: http://php.net/parse_url $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $urlFragment = parse_url( $url, PHP_URL_FRAGMENT ); switch( $urlFragment ) { case '!/page_SPLASH': $title = "Example.com || Splash"; $keywords = "splash content"; $description = "splash description text"; break; /* define more pages here */ case '!/page_HOME': /* no break; intended */ default: $title = "Example.com || Home"; $keywords = "some words"; $description = "description text"; break; }

Categories : PHP

CQ5 - Sling currentPage in model class
you are getting jcr:content/banner because you are calling the resource of a component inside a page, not the page itself. to get the current page from a component you can use the PageManager: PageManager pageManager= resource.getResourceResolver().adaptTo(PageManager.class); Page currentPage = pageManager.getContainingPage(resource);

Categories : Java

Set an AngularJS date filter format to be used by all references to the date filter?
The format defaults to mediumDate if none is provided. There is nothing built in to have it default to something else. https://github.com/angular/angular.js/blob/master/src/ng/filter/filters.js#L382

Categories : Angularjs

Angularjs and filter
It sounds like you are trying to get a list on the code side, not the template. var checked = {}; for(var key in $scope.boxes){ if($scope.boxes[key]) checked[key] = true; // true or $scope.boxes[key], which in your case will be true } // checked will be { "69": true, "72": true, "97": true, "136": true, "396": true} Depending on if you need this value to be constantly updated with each check or not, you may want to put checked in $scope and $watch $scope.boxes, running this for each change. If you only need what is checked before you do something, its best to find what is checked before you do. Just pass $scope.boxes to this: function findChecked(obj){ var checked = {}; for(var key in obj){ if(obj[key]) checked[key] = true; // true or obj[key],

Categories : Javascript

angularjs filter (not working)
Assuming that you'd like to filter in catalogs using distributor name then the following custom filter does the job: <div data-ng-controller="dashboard_controller"> <h1> Catalogs <input type="text" data-ng-model="catalog_filter" placeholder="Filter Distributors"> </h1> <div class="catalogs_listing"> <ul data-ng-repeat="catalog in catalogs | distributorName: catalog_filter:distributors"> <li> <a href="{{catalog.distributor_id}}/d/products/catalog_view/{{catalog.uid}}"> <div class="catalog_thumb"> <div class="catalog_thumb_image"> <span>demo - no image</span> </div> </div>

Categories : Javascript

Filter ng-repeat on Angularjs,
<tr ng-repeat="data in dataset | filter:filterFunction"> <td>{{data.id}}</td> <td>{{data.name}}</td> </tr> Controller: $scope.filterFunction = function(data) { return $scope.filterValues.indexOf(data.id) !== -1 ? true : false; }; $scope.filterValues = [12, 14, 23];

Categories : Angularjs

Angularjs: $filter in controller
I created a demo for you and hopefully you can compare the code and figure out the issue. I guess you might forget to inject $filter module. Please take a look a the demo. <div ng-app="myApp" ng-controller="ctrl"> <div ng-repeat="image in images">{{image}}</div> <button ng-click="order('0')">By orgName</button> <button ng-click="order('1')">By sortOrder</button> </div> var app = angular.module('myApp', []); function ctrl($scope, $filter) { $scope.images = [{ orgName: 'B', sortOrder: 111 }, { orgName: 'A', sortOrder: 12 }, { orgName: 'D', sortOrder: 13 }, { orgName: 'C', sortOrder: 14 }]; $scope.order = function (order) { if (order

Categories : Angularjs

Angularjs filter not null
Angular >=1.3.16 to latest (1.4.1 at time of writing/update) use '' (empty string) (or '!!' also works) <ul> <li ng-repeat="detail in details | filter:{shortDescription: ''}"> <p>{{detail.shortDescription}}</p> </li> </ul> Example: http://jsfiddle.net/TheSharpieOne/1mnachk6/ Angular >=1.3.6 and <=1.3.15 use '!null' <ul> <li ng-repeat="detail in details | filter:{shortDescription: '!null'}"> <p>{{detail.shortDescription}}</p> </li> </ul> Example: http://jsfiddle.net/TheSharpieOne/4wxs67yv/ Angular >=1.2 and <=1.3.5 use '' (empty string) (or '!!' also works) <ul> <li ng-repeat="detail in details | filter:{shortDescription: ''}"> <p>{{detail.

Categories : Angularjs

How to use method as filter in AngularJS?
http://jsfiddle.net/DGKNN/ filter expects there to be an expression that evaluates to a predicate on the scope. That is a function that takes in an element as its parameter and returns whether or not the element should be included in the collection. In your controller: $scope.hasStars = function (message) { return message.hasStars(); }; In your view: <li ng-repeat='message in messages | filter:hasStars | orderBy:"-stars.length"'>...</li>

Categories : Javascript

filter service changes from Angularjs 1.0.3 to 1.0.7
Angular seems to be recognizing your href as unsafe. Try something like this in your configuration block: angular.module('module').config(['$compileProvider', function ($compileProvider) { $compileProvider.urlSanitizationWhitelist(/^s*(https?|ftp|mailto|file|tel):/); /* The regular expression will match your "unsafe" link format and add it to the whitelist */ }]); Here's a more detailed explanation: unsafe link in angular

Categories : Angularjs

AngularJS filter on click
Replace the below line <div class="search-result-property" data-ng-repeat="space in spaces| range:sqrf.sqrf:sqrt.sqrt:type.type | orderBy: sqrM"> with <div class="search-result-property" data-ng-repeat="space in spaces| range:filters.sqrf:filters.sqrt:filters.type | orderBy: sqrM"> As you are updating "filters" variable on "submit" button

Categories : Angularjs

How to optimise the $filter in angularjs?
Please use multiple filters, so you don't have to go tweaking everything Take this example as a starting point http://jsfiddle.net/ed9A2/1/ <tr ng-repeat="player in playersFound = (players | filter:{id: player_id, name:player_name, age:player_age})">

Categories : Angularjs

Using Angularjs filter to differentiate between 1 and 10
There is a way to do this. You can write a custom filter: filter('customSearch', function () { return function (input, searchStr) { if (input == searchStr) { return input; } else { return undefined; } }; }); There is jsFiddle using it. Try to enter "1" and after that "10" into the input field.

Categories : Angularjs

AngularJS filter function explanation
We'll they could just do it the other way! But that's what frameworks about, standardization. Look at the service definition it works in the same way. But if you look closely in the documents it says that .filter function and others like it should get providers not values. This helps in: Lazy or not instantiation. DI and all DI benefits, it lets you define dependency on per-filter basis. Check the full fiddle http://jsfiddle.net/vAHbr/4/ angular.module('myApp', []) .filter('discountcurrency', // The provider, where we can encapsulate our filter // creation code, without having to do JavaScript ninja // stuff. As well as this is our chance to ask for // dependencies. function ($filter) { var currency = $filter('currency');

Categories : Javascript

AngularJS Filter Exact Match
filter can also take a function where you can implement your own filter. I made a plunker showing it in action: http://plnkr.co/edit/v0uzGS?p=preview Here's the relevant code: $scope.ChooseGenreFunction = function(genre) { $scope.filters = function(movie) { return movie.genre === genre; }; }; $scope.ChooseGenreString = function(genre) { $scope.filters = genre; };

Categories : Angularjs

Angularjs filter nested object
Yes, you can, if I understood your example properly. Depending on the size of your collection it may be better to compute the collection you iterate over in ng-repeat so that the filter isn't doing it constantly as the model changes. http://jsfiddle.net/suCWn/ Basically you do something like this, if I understood you correctly: $scope.search = function (shop) { if ($scope.selectedCityId === undefined || $scope.selectedCityId.length === 0) { return true; } var found = false; angular.forEach(shop.locations, function (location) { if (location.city_id === parseInt($scope.selectedCityId)) { found = true; } }); return found; };

Categories : Angularjs

AngularJS: filter a dropdown directive
I found the solution, just add filter:keywordType in the directive template. this is the update link <select ng-model="supplierId" ng-options="a[optValue] as a[optDescription] for a in array | filter: keywordType" required>'

Categories : Javascript

AngularJS - $filter not in global scope
You can use $filter('date') to get the date filter by injecting the $filter module before the actually test stub. I created a working demo for you and please take a look at the required JS files. describe('date', function () { var dataFilter; beforeEach(angular.mock.module('Customer')); beforeEach(function () { angular.mock.inject(function ($filter) { dataFilter = $filter('date'); }) }); describe('date result', function () { it('should return filtered date', function () { var date = new Date(2013, 7, 15); expect(dataFilter(date)).toBe('08/15/2013'); }); }); }); Demo

Categories : Angularjs

angularJS Custom Filter to pull out a particular value
There you go: myApp.filter('FirstAdminThenAlphabetic', function () { return function (array, order) { var comparator; if (order === 'descending') { comparator = function (elm1, elm2) { return elm1.name < elm2.name; } } else { comparator = function (elm1, elm2) { return elm1.name > elm2.name; } } return array.filter(function (elm) { return elm.name === 'admin'; }).concat( array.filter(function (elm) { return elm.name !== 'admin'; }).sort(comparator) ); }; }); You basically filter out all admins and sort that list, than concatenate it to a list wh

Categories : Javascript

How to filter by object property in angularJS
You simply have to use the filter filter (see the documentation) : <div id="totalPos">{{(tweets | filter:{polarity:'Positive'}).length}}</div> <div id="totalNeut">{{(tweets | filter:{polarity:'Neutral'}).length}}</div> <div id="totalNeg">{{(tweets | filter:{polarity:'Negative'}).length}}</div> Fiddle

Categories : Javascript

AngularJS filter with multiple perms
I fixed up your fiddle: http://jsfiddle.net/eQP8S/ <div ng-controller="MyCtrl"> <ol> <li ng-repeat="user in users | filter:{parent_id:0}"> {{user.name}} <ol> <li ng-repeat="child in users | filter:{parent_id:user.id, type:user.type}"> {{child.name}} </li> </ol> </li> </ol> </div> Your main problem was that you were trying to use the "filter" filter with a function, which is okay, but that function isn't allowed to take any parameters. If you actually need to create a filter that takes parameters you have to write a custom filter: http://docs.angularjs.org/guide/dev_guide.templates.filters.creating_filters. But in your case, you can

Categories : Angularjs

AngularJS - filter in script src attribute
I understand that it will be difficult to achieve unless document object has an event that fires before an element is added to DOM and we can manipulate that element's tag in that event handler. For me, the simpler solution was to use a simple REGEX replace at the backend to resolve the pattern with the full URL.

Categories : Angularjs

AngularJs filter "Error while interpolating"
DotDotDot already answered question, but I'd like to improve his answer: return function(list){ return (typeof(list) !== 'undefined') ? list.length : 0; } Update for Angular users: return function(list){ return angular.isDefined(list) ? list.length : 0; }

Categories : Javascript

angularjs custom filter in ng-repeat
After some discussion, the answer was to avoid overwiting existing data by adding a check around the first section of logic like this: if(!(obj.Ticker in tags)){ tags[obj.Ticker] = {id: obj.TickerID, name:obj.Ticker}; if(!tags[obj.Ticker].pending){ tags[obj.Ticker].pending = 0; } if(!tags[obj.Ticker].settled){ tags[obj.Ticker].settled = 0; } if(!tags[obj.Ticker].order){ tags[obj.Ticker].order = 3; } }

Categories : Javascript

AngularJs, filter case insensitive
Pass a function name to filter which you define on an applicable scope, where you use string's toLowerCase. See ngFilter. The function signature is a simple function (item) { ... }. Example JS in your controller: $scope.filterOnlyFoo = function (item) { return item == "foo"; } Example HTML: <div data-ng-repeat="item in items | filter: filterOnlyFoo"></div> Sample Plunker

Categories : Javascript

AngularJs filter on nested ng-repeat
What is the purpose to put the filter on the outer repeater? Just remove it. <div data-ng-repeat="(group, details) in group(reports, grouping)"> Demo

Categories : Angularjs

how to create filter of list
  • using angularJS?
  • I put together a demo of how I would do this, you can view it here. There are a few key differences to your code. The data is stored in an array of nested objects. The filtering is done using an angular filter The tree is rendered using a directive (I got this from someone else's posting a while ago but I can't remember where.. if anyone recognises it let me know and I will credit you)

    Categories : Angularjs

    Angularjs: greater than filter with ng-repeat
    Create the filter as a filter service using the angularjs filter api, and add minPrice as a parameter. filter('priceRangeFilter', function ( location ) { return function ( location, minPrice ) { ... } }) and in the template <div ng-repeat="m in map.markers | priceRangeFilter:minPrice"> See an example in this fiddle: http://jsfiddle.net/Zmetser/BNNSp/1/

    Categories : Javascript

    AngularJS determine filter in controller
    Try something like this: HTML ng-repeat="article in articles | filter:activeFilter[filter]" Controller: $scope.filter = "name1"; $scope.activeFilter = { name1: $scope.someFilterFunction, name2: $scope.someOtherFilter, name3: $scope.andAnother }; $scope.someFilterFunction = function() { var rv = []; for (var p in items) { if (items[p].myFilterProp === false) rv.push(items[p]); } return rv; };

    Categories : Angularjs

    values assigned to a numpy array do not always equal to the assigned values
    The problem seems to be caused by round error. I did a comparison running your code 1000 times using dtypes: float16, float32, float64 and float96; in vector_field and counted the number of times it gives a non zero answer: float16: 1000 float32: 1000 float64: 142 float96: 115

    Categories : Python

    Custom Filter for AngularJS based on a boolean
    Fixed the code for you. Working Demo <div ng-app="app" ng-controller="exampleCtrl"> <select class="span1" ng-model="itemfilter.hidden"> <option value="all">All</option> <option value="hidden">Hidden</option> <option value="shown">Shown</option> </select> <div ng-repeat="item in items| hiddenFilter:itemfilter.hidden:'hidden'">{{item.name}}, {{item.hidden}}</div> </div> var app = angular.module('app', []); app.controller('exampleCtrl', function ($scope) { $scope.items = [{ name: 'Foobar', hidden: true }, { name: 'Foobar', hidden: false }, { name: 'Barfoo', hidden: true }, { name: 'Barfoo', hidden: false

    Categories : Angularjs

    AngularJS Unique Filter then update all Records
    You could use a custom filter that sorts by multiple values. This will allow you to remove the active property from all of your data as well. Let's call it manyToMany and have it take three parameters: an array of objects to sort a string to specify which property on those objects to sort by an object hash of boolean properties whose keys correlate to possible values of the property. The value for any given property will be true if the sort property should include results matching that key. Here is what the filter would look like: .filter('manyToMany',function(){ return function(arrInput,strProperty,objMany){ var arrFiltered = []; for(var i=0,max=arrInput.length;i<max;i++){ if(objMany[arrInput[i][strProperty]] === true){ arrFiltered.p

    Categories : Javascript

    Filter text without HTML tags in AngularJS
    I'm sure there are better ways, but at least this is fairly simple: return $('<div>').html(value).text(); non-jQuery version: var div = document.createElement('div'); div.innerHTML = value; return div.innerText; Create a filter using either of these and put it before your filter:searchText.

    Categories : Javascript

    AngularJS : filter and bold part of the result
    You can make your own custom filter that alters the input based on the search string : angular.module('app').filter('searchfilter', function() { return function (input, query) { var r = RegExp('('+ query + ')', 'g'); return input.replace(r, '<span class="super-class">$1</span>'); } }); This works, but the filter returns html, so you will need to tell angular to treat the result as html. In order to do this, you need to include ngSanitize as a module dependency and insert the result with ng-bind-html. Here's a complete demo : <div ng-app="app"> <div ng-controller="Ctrl"> <input ng-model="search" placeholder="search a fruit" /> <ul> <li ng-repeat="fruit in fruits| filter:search | limitTo:10" ng-bind-

    Categories : Javascript

    Access scope variables from a filter in AngularJS
    Apparently you can. Usually you would pass scope variables to the filter as function parameter: function MyCtrl($scope){ $scope.currentDate = new Date(); $scope.dateFormat = 'short'; } <span ng-controller="MyCtrl">{{currentDate | date:dateFormat}}</span> // --> 7/11/13 4:57 PM But, to pass the current scope in, you'd have to pass this: <span ng-controller="MyCtrl">{{currentDate | date:this}}</span> and this will be a reference to current scope: Simplified: app.controller('AppController', function($scope) { $scope.var1 = 'This is some text.'; $scope.var2 = 'And this is appended with custom filter.'; } ); app.filter('filterReceiptsForDate', function () { return function (input, scope) { return input + ' <strong>' +

    Categories : Javascript

    AngularJS filter exact values with length
    You have to say to Angular that you want a strict comparaison. That's easy to do with Angular 1.1.5, because the filter filter (see the documentation) has now a third parameter, comparator, where true is a very usefull shorthand. In your case, you can simply make something like that : <li ng-repeat="question in questions" id="{{ question.id }}"> {{ question.text }} <ul> <li ng-repeat="answer in question.answers" id="{{ answer.id }}"> {{ answer.text }} (<span ng-controller='AnswersController'>{{ (useranswers|filter:{answer_id:answer.id}:true).length }}</span>) </li> </ul> </li>

    Categories : Angularjs



    © Copyright 2017 w3hello.com Publishing Limited. All rights reserved.