angularjs-ng-include

AngularJS: ngInclude vs directive

邮差的信 提交于 2019-11-26 12:07:53
问题 I do not quite understand when to use a directive and when it would be more appropriate to use nginclude. Take this example: I have a partial, password-and-confirm-input-fields.html , that is the html for entering and confirming a password. I use this both under signup-page and under change-password-page. Those two pages has a controller each, the partial html has no dedicated controller. Should I use directive or ngInclude for this? 回答1: It all depends on what you want from your code

Losing scope when using ng-include

南笙酒味 提交于 2019-11-26 00:45:57
问题 I have this module routes: var mainModule = angular.module(\'lpConnect\', []). config([\'$routeProvider\', function ($routeProvider) { $routeProvider. when(\'/home\', {template:\'views/home.html\', controller:HomeCtrl}). when(\'/admin\', {template:\'views/admin.html\', controller:AdminCtrl}). otherwise({redirectTo:\'/connect\'}); }]); Home HTML: <div ng-include src=\"views.partial1\"></div> partial1 HTML: <form ng-submit=\"addLine()\"> <input type=\"text\" ng-model=\"lineText\" size=\"30\"