This doesn't work. Returns a blank.
$translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (investEdu, mostUltimate) {
Then I tried this, with an object:
$translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (translations) {
Accessing it like `translations.INVEST_EDU'. First one appears, second one blank.
What am I doing wrong here, in making Angular-translate work with multiple translation IDs.
Angular translate usage:
$translate(translationId[, interpolateParams], interpolationId);
translationId [string | array] - A token which represents a
translation id This can be optionally an array of translation ids
which results that the function returns an object where each key is
the translation id and the value the translation.
interpolateParams(optional) [object]-An object hash for dynamic values
interpolationId [string] - The id of the interpolation to use
http://angular-translate.github.io/docs/#/api/pascalprecht.translate.$translate
This means, if you want multiple translation ids you call soemthing like $translate(['INVEST_EDU','MOST_ULTIMATE']).then(function(results){...}
Related
I'm trying to create a page type hierarchy where I can use it both a page hierarchy as well as props and evars, using the page URL. In a nutshell my URL would look something like this:
http://www.domain.com/BrandHomePage/SuperCategory/ProductCategory/Product
The mindset is to take the URL and use a data element to split the URL, and then capture the values into separate data elements that could also be used in a page hierarchy.
var url = "http://www.domain.com/part1/part2/part3/part4"
var parts = url.split('/').splice(2);
console.log(parts);
var baseUrl = parts[0];
var part1 = parts[1];
var part2 = parts[2];
var part3 = parts[3];
var part4 = parts[4]
My question is, would it even be possible to capture each individual portion of the URL into separate data elements? Or is my approach overkill.
Create a Data Element
The following will create a Data Element that returns an array containing up to 4 elements, depending on how many dir levels there are in the URL.
Go to Rules > Data Elements > Create New Data Element
Name it "hier1" (no quotes).
Choose Type Custom Script and click Open Editor.
Add the following code to the code box:
return location.pathname.split('/').filter(Boolean).slice(0,4);
When you are done, Save Changes.
Populate the Hierarchy Variable
Here is an example of populating hier1 on page view.
Go to Overview > Adobe Analytics Tool Config > Pageviews & Content
Under Hierarchy, select Hierarchy1 from the dropdown (this is shown by default).
To the right of the dropdown, in the first field, add %hier1%
Leave the other 3 fields blank.
Leave Delimiter as default comma , (it doesn't matter what you put here).
Note: DTM stringifies the returned array (String(Array) or Array.toString()) from the Data Element, which is effectively the same as doing Array.join(','). This is why the above shows to only put the Data Element reference in the first field, and the Delimiter is ignored.
If your implementation uses a delimiter other than a comma, see additional notes below.
Additional Notes
Populating other Variables
You can also reference %hier1% to populate other variable fields in the Global Variables section. Note that the data element will be stringified with default comma delimiter.
Alternatively, you may consider using Dynamic Variable syntax (e.g. D=h1) as the value, to shorten the request URL. If you are using the latest AppMeasurement and Marketing Cloud Service libraries, this isn't a big deal (the libs will automatically use a POST request instead of GET request if the request URL is too long).
Using the Data Element in Custom Code Boxes
You can use _satellite.getVar('hier1') to return the data element. Note that this returns an array, e.g. ['foo','bar'], so you need to use .join() to concatenate to a single delimited string value.
Using a different Delimiter
If your implementation uses a delimiter other than a comma (,) and you use the same alternate delimiter for all your variables, you can update the Data Element as such:
return location.pathname.split('/').filter(Boolean).slice(0,4).join('[d]');
Where [d] is replaced by your delimiter. Note that this will now cause the Data Element to return a single concatenated String value instead of an Array. Using %hier1% syntax in DTM fields remains the same, but you will no longer need to use .join() in Custom Code boxes.
If your implementation uses different delimiters for different variables, implement the Data Element per the original instructions in the first section. You may use %hier1% syntax in DTM fields only if the delimiter is a comma. For all other delimiters, you will need to populate the variable in a custom code box and use a .join('[d]').
Capturing more than Four Directory Levels
Since you are no longer trying to put a value in four hierarchy fields, you may consider pushing more levels to hier1 or other variables.
In the Data Element, change the 4 in .slice(0,4); to whatever max level of dirs you want to capture. Or, if you want to capture all dir levels, remove .slice(0,4) completely.
My class Posts has a column that is a pointer to another class called Styles. Each post must be associated to a Style object as a rule of thumb.
My problem: I can't get only the posts that are associated to one or more styles.
My object selectedStyles, that is an array of PFObjects that already contains the style objects I would like to use to match the query. So populating the selectedStyles is not an issue, but how to use it to produce my query is.
What I am doing at the moment is:
override func queryForTable() -> PFQuery {
var query = PFQuery(className: "Posts")
query.whereKey("bellongsToStyle", containsAllObjectsInArray: [selectedStyles])
query.orderByDescending("createdAt")
return query
If I could translate the whereKey method in plain english I would say:
...contains - ANY OF THE - PFObjectsInArray [selectedStyles]
I am not so sure if that is possible... any ideas?!
I think I am too late for this but you can just add
[IncludeKey:"bellongsToStyle"]
when you are querying in your 'Posts' class
don't need to run any extra query for that
here's a small reference
http://blog.parse.com/announcements/queries-for-relational-data/
After combining value of two scope variable I wants to apply filter on the resultant output.
Let me explain more clearly where I am stuck.
<h2>{{scope_variable1 | filter_name}}<H2>
Here in my above html I have scope_variable1 in scope which contains string value.This is working fine but I wants to combine value of two scope variables and then i wants to apply filter.
I have one more scope_variable2 and which also contains string value now I want to concatenate both variable's value and then want to apply filter.
Is it possible to do on html element?
As I am aware of other ways to achieve like by using controller and taking third variable in scope but i want to know if it directly possible.
I would like to filter a ng-repeat list of items with multiple catgories checkboxes.
i read this Filtering by multiple checkboxes in AngularJS and watched the videos by Egghead, but i have an error on a simple for loop and i don't understand:
ReferenceError: i is not defined
here is a plunker with the code : http://plnkr.co/edit/p538ALfs00JTFQ6mKT9j
thank you for your help
If you're going to use strict mode ('use strict';), you need to declare your variables. Your checkboxFilter uses many variables that are never defined (i included). You can get past the your initial issues by changing script.js:22-23 to:
var i,j,k,filter_cat,filter_value,filter_name,matchingItems = [];
You have three other problems after that...
Line 37, This code is looking for a property named filter_cat: items[i].filter_cat, when what you wanted was to look for a property name with the value of filter_cat, so this is what you want: items[i].[filter_cat].
Your json data has lowercase field names and your code is searching on uppercase (Type vs type)
Your json data has lowercase values and your code is searching on uppercase (Fruit vs fruit)
Here is a partial edit that gets you on the right track. You'll still need to modify your json or compare lowercase (I partially modified your json): http://plnkr.co/edit/d7p4QthXJg4ao34ATWla?p=preview
The code I am playing around with can be found here.
As of now, in all of my text fields, ng-model has only one name, fieldData. When I take the created javascript object and make it into a JSON object, I get the following:
[{"pHolder":"ID goes here","fieldData":"123"},{"pHolder":"Description goes here","fieldData":"456"},{"pHolder":"Drop Dead Date goes here","fieldData":"789"}]
Since each field has a different meaning, I would like that to be reflected in the bound name.
So instead of an array with three objects that each have the string called fieldData, I would like an array of three objects where foo bar and baz are substituted in each place where there is now fieldData.
How do I do that?
Javascript Array objects are quite flexible, as any other aspect of it, and you can use that to your advantage :) ngRepeat iterates through any array, be it ordered or associative (which are basically the same). So, if you change your array to:
$scope.entryFields = {
id: {pHolder:'ID goes here',fieldData:""},
description: {pHolder:'Description goes here',fieldData:""},
date: {pHolder:'Drop Dead Date goes here',fieldData:""}
};
The ng-repeat element will still work (you may want to reorder it, as it orders alphabetically by key name, by default) without any changes, but you can adress the fields by name (dot notation). See the updated fiddle here.