I'm receiving data from a server containing HTML with variables included.
exemple of data:
content = '<div> I can be displayed here {{variable1}} or here {{variable2}} or any wherelse </div>'
I want to replace {{variable1}} and {{variable2}} with dynamic components in angular upon received from server.
these variables dont have fixed place nor fixed number.
I created a stackblitz where i can find these variables, create the dynamic component but i can't place them in the right place.
https://stackblitz.com/edit/angular-ivy-vcxutx
I think you wanna evaluate a string that came from your backend as an angular expression - which is not a good solution, but in a real world there a bunch of complicated problems - I'm not your jude )
So you have to use $interpolate service here: https://docs.angularjs.org/api/ng/service/$interpolate
Related
I am using angular dart to create a web application.
I have a page where i use material input to get input from the user. in that, i need to have a default initial value in the text box as soon as the page is loaded.
I don't want to bind the input to any variable as this is just a one time use and i will not need binding from component to template after this.
is there a way to specify default/initial value for 'material-input' in dart?
You're probably looking for hintText.
<material-input hintText="Initial value">
</material-input>
From the notes above:
<material-input [ngModel]="value">
Was the solution he used. This will push the value into the input without having it be a two way variable. Nate's suggestion of using hintText is also a good use of this.
New to ember.js -- used http://yoember.com/ to create a Demo ember.js site. I'm trying to figure out how to use Protractor to test certain elements, but I'm encountering issues specifying them.
Most, but not all, elements (buttons, text areas, etc) have a serialized id value: id='ember###' that changes every time the page is reloaded, which makes it impossible to indicate some elements in Protractor (like, element(by.id('ember557')).sendKeys('foo');).
Running a command like the one above will return the error: Failed: No element found using locator: By(css selector, *[id="ember557"]), which is due to the 3-digit id value changing.
In my demo app, I was able to go into the /app/templates/components/ file for that page and manually add something like id='name' into the handlebars input and was able to successfully find and test that element in Protractor.
This isn't ideal though, and I'd like to find a way to test sites that I don't have the ability to modify the html of.
Can anyone help me wrap my head around this? Thanks.
I am working on a coldbox application where I would like to create a route that accepts 'n' number of path variables as one variable. Here is what I mean.
http://localhost/api/variable1/variable2/variable3/...
I would like to either be able to grab everything after /api as one path variable where I can split on / and get the values or be able to iterate over all variables after /api.
Is there a way to setup a Route to do this?
with(pattern="/api", handler="api")
.addRoute(pattern="/:variables", action="index")
.endWith();
Any ideas would be most appreciated. Thanks in advance.
As you probably know, the default routing paradigm is to do name value pairs like so:
http://localhost/api/name1/value1/name2/value2/name3/value3
There is no need to create a custom route for that as everything after the matched part of the route is broken up into name/value pairs and placed in the rc automatically.
Now, it sounds like you're wanting to only have values in your route. If you know the maximum number of variables you'll ever have, you could create a route of optional, incrementally-named variables.
addRoute(pattern="/:var1?/:var2?/:var3?/:var4?/:var5?", action="index")
Now, if you truly might have an unlimited number of variables, there is no way to do a route that will match that. What you CAN do is have your route match the /api bit and write an onRequestCapture interceptor that grabs the URL and does your own custom parsing on it. Note, you may need to remove the name/value pairs that ColdBox will try to put in the rc.
I will add a note of caution-- the only way for this to really work is for you to KNOW the order of the incoming variables ahead of time, and if you know that, there is no reason why you can't create a known route for it. Otherwise you're basically rebuilding the SES interceptor over again which is an anti-pattern called "inner platform effect"
http://wiki.coldbox.org/wiki/URLMappings.cfm#URL_Mappings
http://wiki.coldbox.org/wiki/Interceptors.cfm#Core_Interception_Points
http://en.wikipedia.org/wiki/Inner-platform_effect
I started using cppcms to make a simple website + "service" that gets its input from the path like:
/maindb/2012/11/2/finalists/....
now i noticed that the nice url handling has only a regex dispatcher up to 4 parameters that will be given to the called function and a function without regex gets nothing at all not even the path.
Now what is the most feasible way to realize more than 4 parameters / subfolders.
Do I have to write my own url handling and if so where do i get the url from?
Is the url class public enough to iherit it and just extend it easiely for longer functions?
Or is there some other way how I am supposed to do it? (because 4 parameters seems kinda very less)
Two points:
If you have subfolders you are probably looking for organizing your URLs into hierarchy. See
http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hierarchy
If you need more then 4 parameters you should:
Check if you really organize your application right (see above)
Combine several cases into single regex and split them afterwards in a parameters
For example (/\d\d\d\d/\d\d/\d\d)/(\w+) where the first would mach the data and not separatly year, month day.
P.S.: Url dispatcher is not designed to be derived from.
Say I request
parent/child/child/page-name
in my browser. I want to extract the parent, children as well as page name. Here are the regular expressions I am currently using. There should be no limit as to how many children there are in the url request. For the time being, the page name will always be at the end and never be omitted.
^([\w-]{1,}){1} -> Match parent (returns 'parent')
(/(?:(?!/).)*[a-z]){1,}/ -> Match children (returns /child/child/)
[\w-]{1,}(?!.*[\w-]{1,}) -> Match page name (returns 'page-name')
The more I play with this, the more I feel how clunky this solution is. This is for a small CMS I am developing in ASP Classic (:(). It is sort of like the MVC routing paths. But instead of calling controllers and functions based on the URL request. I would be travelling down the hierarchy and finding the appropriate page in the database. The database is using the nested set model and is linked by a unique page name for each child.
I have tried using the split function to split with a / delimiter however I found I was nested so many split statements together it became very unreadable.
All said, I need an efficient way to parse out the parent, children as well as page name from a string. Could someone please provide an alternative solution?
To be honest, I'm not even sure if a regular expression is the best solution to my problem.
Thank you.
You could try using:
^([\w-]+)(/.*/)([\w-]+)$
And then access the three matching groups created using Match.SubMatches. See here for more details.
EDIT
Actually, assuming that you know that [\w-] is all that is used in the names of the parts, you can use ^([\w-]+)(.*)([\w-]+)$ instead and it will handle the no-child case fine by itself as well.