Mean.JS Angular - Returning a single result - angularjs

Im trying to learn Angular.js and have a small problem here. I have created a page that views ALL customers but what im trying to figure out is how to create a page where you just have an individual customer.
On the list all customers page i have
data-ng-repeat="customer in customers"
which returns all customers but how do i just limit that to an individual result on the view single customer page. The URL is customers/55b4fb75778becf4255b2ea5 so i assume it needs to be something equivalent to WHERE customer.id = "55b4fb75778becf4255b2ea5"

i believe ur using routes to show details of a particular costumer from a list
try using this within element
{{customers[whichItem].name}}

Related

Filter and display mongodb documents

I'm fairly new to MongoDB so I apologize if my terminology is incorrect. I'm working on an e-commerce project (learning project) with express, mongoose and ejs, and I want to add a filter option into the 'All products' page. So for example if someone wants to view 'Sports' products only, I'd like to be able to update (PUT) the current page with 'Sports' products only.
To achieve this right now with my current skill set, I would create a separate route for each product category, /products/sports and then Product.find({ category: 'Sports' }) in my controller, and then display it in my ejs file with something like
<% sportsProducts.forEach(product => { %> <% display each product here %>
I feel like this is not the right approach at all, as it would be difficult to scale the project, and I could run into issues with displaying a certain amount of products per page. Is this something I need an API or AJAX for? I would much rather stay away from those if possible.
I'm just hoping someone can point me in the right direction, since a lot of mongodb's capabilities are unknown to me
Here you can follow these two approaches
make your route as dynamic like /products/:category then in code
Product.find({category:req.params.category})
Add a category as query param in your route /products?category=sports
Product.find({category:req.query.category})

How to show recently record list on my custom visualforce page?

The sObject's record list
Hey, I have a question, when I click a sObject's tab it will present a standard page. The picture shows the recently record list, is it a standard function like "apex:listViews" mark-up tag? I want to achieve this function in my own custom page. How do I do this?
I don't think there's a dedicated VF tag for it (aside from some very specialised cases like Knowledge and Ideas-related tags). But you can manually query it from database and display in <apex:pageBlockTable>.
There's a table with "recently viewed everything, across all objects" (think of it like "Recent Items" sidebar in clasic SF UI): https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_recentlyviewed.htm
And also most objects will have a LastViewedDate field so you should be able to do
SELECT Name
FROM Restaurant__c
WHERE LastViewedDate != null
ORDER BY LastViewedDate DESC

AngularJS dynamic table - RESTfull data

I have a big data portion that I would like to post in a table. However, the data should be sorted and paginated. I know I am able to pass the whole data to the client at once and then paginate it using angular, but this will be too slow. I prefer to pass the data page-by-page, so one the client want to open a page from a table to load the data for it.
Up until now I have created an API that returns me the data that I need, based on the page number and the number of rows on the page. However, I don't know how to use it with AngularJS.
Can you please help me?
It looks like a backend problem. If you are using a standard restful backend, use the limit/skip parameters, you can encapsulate into a paginate.
Example:
localhost:1337/dataTable?skip=0&limit=100
localhost:1337/dataTable?skip=100&limit=100
localhost:1337/dataTable?skip=200&limit=100
...
On the frontend use a table object like ng-Table, and use the pages to keep track of the offset, the page number and the total items available.
skip = (pagNum - 1 * pageSize)
limit = pageSize
Make your backend return you the page you want plus the available dataNumber so you can build the pages controller.
Documentation for skip/limit on sails
http://sailsjs.org/documentation/reference/waterline-orm/queries/limit
http://sailsjs.org/documentation/reference/waterline-orm/queries/skip
Best approach is to keep track of the limit and offset in your controller. Then when user selects new page (offset) or changes items per page (limit), update the corresponding values and use them to make a new http request.
You could call a function on ng-change of a dropdown and that drop down would contain values of page number and number of records to fetch. Or you can provide two text boxes one for page number other for number of records and keep a button and on its ng-click event that will take value of those text boxes and post to your server and bring back data based on new values in text boxes

Angularjs How to manage Code

I am new to Angularjs. I have a page like this.
I have a single controller which does all the work which is currently working fine. I want to manage my code to use angular-given-functionalities by using filters, services, controllers etc.
In this page i have many sections i am mentioning here.
Search filters
Category
Attributes
Tags
Pagination Section plus Grid or List links
Sort plus Compare section
Product data to display
How can i break my code in separate chunks to manage it properly.
I have created a service which does all ajax related work.
Here is the dependency.
1. Search does nothing except page redirect
2. Category can have a view more which will update itself will more then 10 records
3. Attributes can have viewmore button to display more then 10 attributes. Attribute can also impect on the following
When we select single on multiple attribute it will change
1. Category
2. Attributes
3. Tags
4. Pagination
5. Listing (Product data to display)
4. Tags can be removed and can have excatly same behavior as Attributes
5. Pagination will change itself and product data display
6. Sort will have same as pagination
7. Nothing
I dont need code just some suggestions on how can i choose things from Angular to make managed code.

Pyrocms Getting Values at front end

I am new to pyrocms.
How can I get database values on pages of pyrocms. In website of pyrocms I had created a listing page now I want to display database values from pyro database table.
I got your question, you want to create a listing on your front-end page for some database table values which you want to access through your custom module controller. there are many ways to get these values but the simplest way is to use ajax. you already have Jquery added in pyrocms so you can simply make a call to your controller method in ajax and get your required output as HTML and display it in the div element on your page.
$.ajax({
type:"POST",
url:"admin/your-controller-name/your-method-name",
success:function(html){
$('yourdiv').html(html);
}
})
In your controller create a method which get data from database and print it using echo create some listing table etc what you want.
i think you will get my point. if confuse then get back to me
You need to be more specific as PyroCMS has lots of components and each module (blogs, variables, widgets, file uploads etc.) uses specific tags you insert into the page. You may come across references to 'Lex' - that's the name of the parser used to display them.
Tags documentation
PyroCMS (the Professional edition) also has a feature called "Streams" which allows you to build custom databases and this in turn has it's own series of tags.

Resources