最近我遇到了一个测验,问题是
Decorators use
Select one:
a. Both
b. $delegate
c. None
d. $provide
Run Code Online (Sandbox Code Playgroud)
我选择 b.$delegate,测验说它错了,测验说正确答案是 a.Both。
所以我想知道这是否属实,我认为装饰器在提供者内部,即它们是由提供者调用的服务,他们可以像在这个例子中一样使用 $delegate
app.config(function ($provide) {
$provide.decorator('movieTitle', function ($delegate) {
return $delegate + ' - starring Keanu Reeves';
});
});
Run Code Online (Sandbox Code Playgroud)
此外,在装饰器文档中,它指出
该函数将在服务需要实例化时被调用,并应返回修饰的服务实例。该函数是使用 injector.invoke 方法调用的,因此是完全可注入的。本地注入参数:
$delegate - 原始服务实例,可以进行猴子修补、配置、装饰或委托。
所以,我是不是遗漏了什么,或者是测验错了,还是我错了,有人可以帮我理解这一点。
我正在使用角度数据表,并且只有一列。
当我绑定它时,数据按升序排列,而我想按接收到的顺序显示它。
有人可以帮忙吗?
控制器:
var vm = this;
vm.dtOptions = DTOptionsBuilder.newOptions()
.withButtons([
'print',
'pdfHtml5',
]);
vm.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).notSortable()
];
Run Code Online (Sandbox Code Playgroud)
HTML:
<div ng-controller="formViewController as frmView">
<table datatable="ng" dt-options="frmView.dtOptions" dt-column-defs="frmView.dtColumnDefs" class="row-border hover">
<thead>
<tr>
<td>
{{Title}}
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="plugin in newArray track by $index">
<td>
//Content
</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud) 我想知道angular2中是否有cacheFactory?如果有,有人可以提供一些技术教程吗?关于如何使用它的简单介绍将非常感激!
PS:现在,我正在尝试将angular1项目移动到angular2,我遇到了使用cacheFactory的问题.