I am adding some number of textbox controls on a button click and entering some text on each textbox, then am navigating to another one page, and coming back to my initial page. am not able to see my textboxes...
Is there any way to keep my textboxes and values of each textbox in angularjs?
Create a service or factory to communicate between different controllers or in your case page.
Please refer this. Hope it gives you some idea.
Thanks
Related
I have a problem with a custom directive that I wrote to simulate a tab view in angular.
This directive has only a method to redirect from a state to another.
This directive works fine.
The template of the directive is a div with a uib-tabset and some tabs that contain the views to show them.
This works fine.
Now I need this feature: from a view in a tab, I need to change view with a state.go(view) and I must also go to the tab which contains that view.
I tried different solutions that I found here or in other forums, but probably my requested feature is different from others.
Thank you.
I resolved with the answer in this link.
Sorry for my repost.
Angular UI bootstrap tabs - Can't change tabs with a button inside a tab
I have set of tabs and a combo box(for time frame) in top.html file , which loads in all pages.
I am rendering the pages according to tabs selected using angular JS.
I want the view to update when time frame is changed using the combo box , i.e to call respective controller of that page.
I have no clue what page is currently rendered as the combo box is in different file.
Is there any way of invoking the controller on event change ?
use respective event and call the method of controller. For example you can call controller method on click event using ng-click,and similarly so on.
I hope it may help you.
I’m very impressed with Josh's answer about ‘angular way’ and declarative style in client-side.
But can you help me to understand, how to do that:
I have a single-page app with the menubar in the left side, and div container on the right-side.
When user clicking the menu item in the left menubar, on the right side I must to open the new tab with some grid,like this:
In angular I realized the <grid> directive.
When user click menuitem, I must add dynamically this grid directive with params on the right side.
What is the angular way for doing this functionality?
Update:
I found article about dynamic tabs, and this is example how I use it in my case
Since you asked a general question, let me give you a general answer. It should be helpful :)
AngularJS is model/data driven, and if you want to make any change to the UI, the first thing you may think is how to achieve it by changing data. Given this idea, we can implement it like this:
Define a ng-repeater, which should render tabs for a list of Tab objects called MyTabs, for instance.
When you want to add a new tab, then create a tab object and add/push it to MyTabs.
AngularJS will magically render it on the UI, thanks to the 2-way data binding.
I have a use case to toggle the view of a form using a button. The button is not nested in the same structure of the form, and is out side the scope of the forms controller.
What is the best way to have this toggle button comunicate to the contents controller to display this content?
I have had a similar problem and for advanced comunications between controllers i would recomend a service. A service can be injected into multiple controllers so they can share information & state.
However if all your after is something like a button that you can place anywhere that will show the form, you could consider using the $location.path?
eg. on a view with a list of users
www.example.com/users
append edit
www.example.com/users/edit
then have the form controller watch the $location.path and open itself when it see's edit ?
With angularjs, we usually use plain HTML to write views. Now I have a question: how can I show or hide some buttons depend on the user's rights?
For example, current page is displaying an article. If the current user is the author or the article, or administrator, then "Delete" button will be displayed.
But since the view is plain HTML, how can I control it?
I can post an request to pass some data(e.g. current user id, article id) to server to check, but if there are many buttons, I need to request many times, which is not effective.
Is there any better way to do this?
You can use the ngShow directive. I put together a little demo, but the important bit is simply:
<button ng-show="user.id==post.postedby">Delete</button>