我试图在ng-repeat中动态添加不同的指令,但输出不被解释为指令.
我在这里添加了一个简单的例子:http://plnkr.co/edit/6pREpoqvmcnJJWzhZZKq
控制器:
$scope.colors = [{name:"red"}, {name: "blue"}, {name:"yellow"}];
Run Code Online (Sandbox Code Playgroud)
指示:
app.directive("red", function () {
return {
restrict: 'C',
template: "RED directive"
}
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<ul>
<li ng-repeat="color in colors">
<span class="{{color.name}}"></span>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
如何使角度拾取class
通过ng-repeat输出的指令?
我有一个具有2个依赖项的服务:存储库和网关(短信).
我需要解析2个不同版本的服务,这些版本仅在传递给网关的其中一个参数上有所不同.
代码简化如下
public interface IService
{
string DoSomething();
}
public interface IServiceFoo
{
string DoSomething();
}
public interface IServiceBar
{
string DoSomething();
}
public interface IRepository { }
public class Repository : IRepository { }
public interface IGateway
{
string Name { get; set; }
}
public class Gateway : IGateway
{
public string Name { get; set; }
public Gateway(string name)
{
this.Name = name;
}
}
public class Service : IService, IServiceFoo, IServiceBar
{
private readonly IGateway …
Run Code Online (Sandbox Code Playgroud)