How to specify model to a ngInclude directive in AngularJS?

前端 未结 6 1713
北海茫月
北海茫月 2020-11-30 02:48

I would like to use the same HTML template in 3 places, just each time with a different model. I know I can access the variables from the template, but there names will be d

6条回答
  •  粉色の甜心
    2020-11-30 03:44

    There is a pull to fix this but it looks like it's dead: https://github.com/angular/angular.js/pull/1227

    Without modifying the Angular source code this will solve the problem in a reusable not-too-hacky-feeling way:

    directive('newScope', function() {
        return {
            scope: true,
            priority: 450,
        };
    });
    

    And an example:

    Here is a Plunker of it in action: http://plnkr.co/edit/El8bIm8ta97MNRglfl3n

提交回复
热议问题