0

I have a view in which I am listing out existing contacts.

  • route : /contacts
  • controller : contacts.list
  • view : /templates/list.html

I have another view in which I want to add a new contact

  • route : /contacts/add
  • controller : contacts.add
  • view : /templates/add.html

Using route, I am able to show either of these when needed.

But the challenge I am facing is to show the add form page in a popup when clicked on Add button instead of replacing list view.

Basically I want to link "Add" with the /contacts/add URL which will load the view in a popup and bind the controller to it, instead of replacing the entire view.

Please help me in how to think in Angular to achieve this.

Following is what I have currently.

var myModule =
  angular
    .module('myModule', [])
      .config(['$routeProvider', function config($routeProvider){
        $routeProvider
         .when('/contacts', {
           controller : 'contacts.list',
           templateUrl : 'templates/contacts/list.html'
         })
         .when('/cotnacts/add', {
           controller : 'contacts.add',
           templateUrl : 'templates/contacts/add.html'
         });
    }]);
2

1 Answer 1

0

You might want to map angular routes to custom events and not really using <ng-view>

See this: www.bennadel.com/blog/2420-Mapping-AngularJS-Routes-Onto-URL-Parameters-And-Client-Side-Events.htm

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.