I have to create an Angular website. The first page has static content and I made the second page with an ngfor because I got a JSON file with a tree structure of a productrange and with that I wrote a method which get me the node I selected on the static website. On the static website I gave hard coded key params, which I used in the next component to get my node because the JSON file had a key as well and I had to get the selected node with this key. But the second page content get loaded with and ngfor, which loads a list, that I get from the treemodel so I don't have a fix key, and I don't know how to get the key I want. I will send some screenshots with this question so you maybe get what I want to ask.Code of the first static page with the hardcoded keys:
My both router paths in the app routes ts:
How i get my key param as a string:
My loops to get the data from the tree into arrays:
The ng for with the key param which i dont know how to get out when i click on one of the elements in the last screenshot:
This is the page, which got loaded with the ng for:
Related
I'm using the following url for my JSON data.
myapp/laravelRoute/jsondata
when entering this in address bar, following JSON array will be displayed
[{"A":"B"},{"B":1},{"C","http"}]
But, when I enter the url as,
myapp/laravelRoute/jsondata?search=B
it shows the entire array instead showing the search result. How I do this correctly?
After doing the code view I found that the array route is configured for a default route in Laravel Routes. So, in any case that open a path except mentioned ones in routes will redirect to the default path.
I have a React web-app, which loads a JSON file from the server. The content is then sent as props down to several components.
Some of the "nodes" in the JSON file contain further references (URLs), that needs to be loaded. Kind of like a HTML page.
I'd like to do this asynchronously, so that (just like a browser) I render what I can, and when the further references have been loaded I render those parts.
How would you do this?
What I can think this far is to have every component be robust for missing data (if a URL is found instead of the data, show "loading" indicator), and then just trigger setState when more data come in. Any better ideas? RxJS or some super library?
BTW: I'm not using Redux -- just props/state ATM.
I'm doing a web app based on original MEAN.js framework. When I want to request local json test file using $http.get() method in my AngularJS file, it returned my index html content.Is it a routing problem? I didnot change the original mean.js routing code(https://github.com/meanjs/mean), just added a $http.get() method in home.client.controller.js file. Can anyone help me with this? Thanks!
That is most likely happening, because you didn't define an endpoint for that particular GET request in your app.
Everytime you make a request to your server (for example a GET request to /my-request) nodejs/express are configured in MEAN.js so that your server will try to find the endpoint for that request, if it does not find any, that request will be handled by this particular code block (specified in /modules/core/server/routes/core.server.routes.js):
// Define application route
app.route('/*').get(core.renderIndex);
Which will basically render the index view.
I'm not sure if you're using a custom module or not, eitherway, if you want that request to be handled in a different way in MEAN.js, you can specify your endpoint in your custom module routes file (or in core.server.controller.js) like so:
// Define application route
app.route('/my-request').get(core.sendMyJSON);
Be careful, because this route must be placed before the one I mentioned earlier, otherwise your request will still be handled the same way and the index view will be rendered and served again.
Then you will have to create the controller that should be called to handle that request:
exports.sendMyJSON = function (req, res) {
// logic to serve the JSON file
};
This way you should be able to get it done with a few adjustments.
Side note:
I'm not entirely sure but I think if you place your JSON file in the public directory of your app you should be able to directly access it without the need for the extra logic.
Let's say I have a page in CQ5. I created this page using a template with a single component, call it tableComp, and I hit at url Test.html. The component contains its standard JSP file but the page template being used also contains a specific JSP for JSON or XML rendering of custom data, not page data.
This JSP file for rendering would be named something like data.xml.jsp or data.json.jsp. To hit this rendering JSP for the page Test.html you would call /content/{org}/desktop/en_US/{name}/Test.data.json or /content/{org}/desktop/en_US/{name}/Test.data.xml.
The XML/JSON JSP would be called which contains code to just get values and print to the screen XML or JSON. Ex: Blah
Now I want to display information to the screen as a JSON output when I hit a new file named data.json.jsp. When hitting data.xml.jsp it works correctly and hits the JSP. When I do the exact same process for the data.json.jsp I then get the following.
Invalid recursion selector value 'data'
Cannot serve request to /content/{org}/desktop/en_US/{name}/Test.data.json in org.apache.sling.servlets.get.DefaultGetServlet
Request Progress:
0 (2015-07-22 18:10:06) TIMER_START{Request Processing}
0 (2015-07-22 18:10:06) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
0 (2015-07-22 18:10:06) LOG Method=GET, PathInfo=/content/{org}/desktop/en_US/{name}/Test.data.json
I have tried adding a Pages.json.jsp file to the /libs/foundation/components/primary/cq/Page section as suggested in another forum but this did not help. The content of this Pages.json.jsp file was <%#include file="proxy.jsp"%>.
How can I get JSON to work for this type of request?
EDIT:
I have changed my original explanation to clarify my problem.
Looks like the request is being handled by the DefaultGetServlet which in turn uses the JsonRendererServlet to process your requests with .json extensions.
Since the JsonRendererServlet requires a numeric selector or the infinity selector, it throws the following error.
Invalid recursion selector value <<selector>>
However requesting /Test/_jcr_content.data.json would render the JSON data processed by the data.json.jsp instead of the DefaultGetServlet.
I am getting a JSON file from an URL which contains some movie data.
http://movieapp-sitepointdemos.rhcloud.com/api/movies
I have checked in Postman it works fine and showing data also. But when I try to show data on angular using ng-repeat it does not show.
Please check why data is not displaying on it.
Here is my plunker
thats because in your movies object contains only {"message":"Movie Added"} object
here you can see example, ive updated , ng-repeat works as expected in another batches object , and also you can see what you get from server at the first line