我需要动态生成'div'而不需要ng-repeat和范围内的不同数据。
<div attribute={{atrb}}>{{name}}</div> (<- dynamic div).
控制器
$scope.GenerateDiv = function()
{
$scope.name = "praveen";
$scope.atrb = "01";
}
答案 0 :(得分:3)
答案 1 :(得分:2)
You can do it like
$scope.str = ''
for ( i = 0 ; i < arrayofdata ; i++ ){
$scope.str += "<div>"+arrayofdata[0].ex+"</div>"
}
use Sanitize filter the following link contains log
https://docs.angularjs.org/api/ngSanitize
then create html like this
<div>
{{str | Sanitize}}
</div>
答案 2 :(得分:1)
如果是单 ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
SimpleModule module = new SimpleModule();
module.addSerializer(ZonedDateTime.class, new JsonSerializer<ZonedDateTime>() {
@Override
public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
jsonGenerator.writeString(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZZ").format(zonedDateTime));
}
});
objectMapper.registerModule(module);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
,则使用div
来控制其创建:
ng-if
如果不满足条件,则不会创建<div attribute="{{atrb}}" ng-if="name">{{name}}</div>
。当条件成立时,div
将添加到您的DOM中。
如果您需要其中几个,请将参数存储在数组中并使用div
。