I think the local provider for a directive is to provide services for its content children, for example:
//template in a module
<table>
<tr>
<td>{{ item.price | myPipe }}</td>
</tr>
</table>
myPipe has a dependency of MyService in its contructor:
So if I define a directive as:
@Directive({
selector: "[myAttr]",
providers: [MyService]
})
export class MyDirective { }
and apply it as:
<table>
<tr myAttr>
<td>{{ item.price | myPipe }}</td>
</tr>
</table>
then MyService in myPipe's constructor can be resolved.
But if there is a component also define MyService in its local providers and apply it as:
<myComponent>
<tr myAttr>
<td>{{ item.price | myPipe }}</td>
</tr>
</myComponent>
since both the MyDirective and MyComponent can provider the service for myPipe, so which one will myPipe choose, local provider of MyDirective or MyComponent?