how to protect master page controller affected in child page in angularjs - angularjs

I have a controller and model in my asp masterpage
so,that my other content pages not working.Content pages having seperate controller and model in angular js

Have you tried controller as syntax? You may find it here ngController doc.
So you may isolate your master page controller by naming it somehow, for example MainMasterPageCtrl.

Related

UI-Router Multiple Views Single Controller example

i new in angularjs.i have same question UI-Router Multiple Views Single Controller response it was stated
You basically need to handle this kind of stuff in some sort of provider (typically a service or a factory)
You can give an example?

When talking about AngularJS, what exactly is the view?

When talking about AngularJS, what exactly is the view? Or can it be more than one thing?
View is what the user sees (the DOM).
Normal HTML in Angular is called template. When Angular starts your
application, it parses and processes the markup from the template
using the compiler. The loaded, transformed and rendered DOM is then
called the view.
Have a look at the following image:
Source: https://docs.angularjs.org/guide/concepts#view
All your HTML pages are the view. JS files are usually controllers or services.
HTML is the user interface (the view) and JavaScript is the engine of the application, consists mainly of controllers and services (see Angular's service as a model).
So, the view is all the user could see.

How to communicate scope data through multiple angular app?

I have separate login ng-app and index page ng-app
So how would I get LoginData scope into index ng-app?
you create a service and inject it as dependancy in your two controllers to share data between them.
a service is a singleton.
many source on google, search "angularjs share data between controllers" :
a good solution here
Share data between AngularJS controllers
You can do that using localStorage (HTML5) through angularJS

Is it compulsory to define ngRoute on the angular module?

I am absolutely novice to angular.js and i have some confusion, is it compulsory to define ngRoute on the angular module, as far as i think that it is require to include if we want to change the view on the basis of URl change.
Or is it also possible to define the route and return the view manually by calling some controller and on button click and it will return a view that i can use in the my index page.
You can create a app without using ngRoute. In that case you do not use the nv-view directive in html and the app does not respond to url change.
Also in that case if you want to change any part of the site, you use ng-include which takes parameter as the view name on server and it can be dynamically changed based on some logic.
Said that, you should use the view segregation and loading based on route as it makes your application a truly single page app, where views are update without any page refresh and each of the individual views can be bookmarked.

How to switch out only a specfic "view" of the page in angularjs?

I have an index.html with an ng-view within the page at a specific region. I want to make it such that when I click on a button on the page, the ng-view switches to another view, but without having to define a new route or trigger a route change. The following options are what I am thinking:
A main controller around everything. Each region/view would have its own controller (subcontroller1 and subcontroller2). Main controller has the responsiblity of switching views when appropriate without route.
Is this the right train of thinking? Are there any examples of switching just a part of the page?
For the first part of your question : no, you can't partially use ng-view. There is only one ng-view per angularjs app, and the ng-view switches to another view according to the router.
You can load specific part of a page by using ng-switch, so that only part of the DOM are loaded according to the value of the ng-switch : http://docs.angularjs.org/api/ng.directive:ngSwitch
Probably the closest answer to your question is to have look at the ui-router, in order to use nested routing : https://github.com/angular-ui/ui-router

Resources