Differentiating two views with same controller for different user in angular - angularjs

I have two different views of each page in an application. One view is the editable view where a user can come and edit stuff.This view has Buttons, Text Input, Text Area etc. The other view is used to just view the data. The buttons should be hidden, Text Input, Text Area which were editable should be replaced with label.
So I have a doubt whether I should have:
(i) two different html files for each view which can be changed inside the router
(ii)same html file and use ng-if
(iii)same html file and create directive for each change

This depends on how many ng-if directives you have to create. In other words how large your view is.
If it is a small view - go for ng-if.
If not, use a separate template for the view.

Related

How do I hide certain fields from different templates in 2sxc apps using Formulas?

I have an App called "Features"
In Features, I have these fields:
Heading
Text
Image
The app has two separate razor templates. One of the templates displays an image, and the other one does not.
How can I hide the "Image" field from Template B, but still display it in Template A? Is this possible with Formulas? If so, how?
Yes, this can be done with formulas ;)
Best check out the current Content Templates, the basic-content (text/image) templates have exactly this implemented.
If you open it from a template which doesn't show images, the images-field is hidden (but the editor can reactivate it). So this is quite sophisticated, you can also do simpler implementations.
Basically the steps are:
Create an ephemeral field which just serves as a temporary variable to determine if it should be shown by default or not - we usually call it something like VarShowImage - probably default to true (so if it's not set, it's true when the form loads) https://docs.2sxc.org/basics/data/fields/ephemeral.html
In the toolbar where it should be hidden, prefill this like VarShowImage=false
On the field which should be hidden, create a formula to control visible based on this field

Load several views in one page

I would like to print the content of several views of my couchDB database inside a page.
I have several listContainers in my page and each listContainers must print the content of one view.
To do that I added an "onDidLoad" event to my page which triggers several QueryViews (one QueryView per view).
I correctly binded the content of each ListContainer with its corresponding view.
My problem is that all the lists print the same content which is the content of the last loaded view. All the views seem to be loaded but only the last view loaded is taken into account.
Is it possible to have several QueryViews for one page and how can I load the content of different views inside one page ?
Yes, it is possible to have multiple Query view components in one Page. Use the Marker property to set a different value for each component. In the MobileComponent Source you will find all your views marked as myView#myMarker. Select corresponding view markers for your listContainers.

watch on scope variable of one controller and send it to other controller

I have following requirement.
I have two divs, both are render using custom directives. div1 contains one search textbox and div2 contains tree view control. when user types something in textbox, based on that search word, one service will be called and related data would be bind to TreeView in div2.

<select> tag brings up dynamically a different set of input fields depending on selection in AngularJS

Im trying to create a form, first element should be a tag with a few options and each of them will dynamically bring up a different set of forms depending on what the user chooses. The idea is within the select tag there will be different categories like cars, properties etc.. first user only sees that and when chose, it will bring up a set of input fields that required for that category.
Anyone got an idea what would be the best way to do it in angular?
Using the ui.router module, you can populate a DOM element (ui-view) with an HTML template file. On selection of the dropdown, you're telling angular to go to a different "state".
Check out the following plunkr I made: http://plnkr.co/edit/jnKQOvkE4nJinEQ5zhr6?p=preview

Drupal 7 - how can I control content layout in a view?

I've been handed a design spec which requires a news listing in a specific format - e.g. image floating to the left, with the main title and content on its right.
I've created the articles listing using the views module and embedded the view as a block on the front page. However, I need to change the layout of the resulting list of items at an html level, as the items are not provided in the order or within the html tags that I need in order to deliver the design.
In order to style the output, I really need the views module to give me fine-grained control over the html tags being wrapped around each field for each article.
Is this possible in Drupal?
(edit: please note, this is not a css question - I know how to float and position things in css. I need to be able to modify the html tags applied to fields in a view - thanks!)
When you go to your view, you will see FORMAT. You can change the Format to HTML list with corresponding settings. Under Show, you will say Fields. In the FIELDS area, choose which content you want enabled. Let me know if this helps, or if you want more of an explanation. Go back into your view and click on your field. The next window that pops up should be to configure that field. You'll see style settings where you can define the HTML tags, classes, wrappers, etc.

Resources