0

I have created a view (A HTML file consisting of some divs and input boxes) and now I want to use that file as a view at different places but with different data models binded to it. "I mean change in ng-model of input tags"

One way is to make same view again and again and bind it with respective data model. But I don't want it.. How can I use only one HTML file as a view and bind it with different model at different place?

P.S : I am somewhat new to Angular-JS

CoderBoy
  • 33
  • 7
  • 1
    It depends on what you mean by *use that file as a view at different places but with different data models* but in many cases a html file can be used as a template – Tim Jun 06 '14 at 14:01
  • "I mean change in ng-model of input tags " – CoderBoy Jun 06 '14 at 14:08

1 Answers1

1

Do you mean useing different controllers with the same html template? If your using ngRoute you could set it up like this

$routeProvider.
  when('/route1', {
    templateUrl: 'myView.html',
    controller: 'myCtrl1'
  }),
  when('/route2', {
    templateUrl: 'myView.html',
    controller: 'myCtrl2'
  });

Here is a tutorial on setting up routing: https://docs.angularjs.org/tutorial/step_07

rob
  • 17,995
  • 12
  • 69
  • 94
  • With this can I operate on say array1 with myCtrl1 and array2 with Ctrl2? I think I can but to be sure... – CoderBoy Jun 06 '14 at 14:13