1、问题背景
给定一个数组对象,里面是差异的id;循环生成差异元素,并给编号赋值
2、实现源码
!DOCTYPE html html head meta charset=' UTF-8 ' title angularjs动态生成差异的ID/title脚本src=' http :http://apps。bdimg。com/libs/angular。js/1。4 .6/棱角分明。量滴js '/script脚本var app=angular。模块(' idApp ',[]);app.controller('idCon ',函数($ scope){ $ scope。divides=[{ divided : '图表id 1 ' },{ divided : '图表Id2 ' },{ divided : '图表Id3 ' },{ divided : '图表Id4 ' },{ divided : '图表id 5 ' }];});/script/head body ng-app=' IdaPP ' ng-controller=' IDcon ' div ng-repeat=' chart in DiVId ' DiVId id=' { { chart。DiVId } } ' { { chart。DiVId } }/div/div/body/html 3,实现结果
htmlheadstyle类型=' text/CSS ' @ charset ' UTF-8 ';[ng :斗篷],[ng-斗篷],[数据-ng-斗篷],[x-ng-斗篷],ng-斗篷x-ng-斗篷ng-hide:not(.ng-hide-animate){ display : none!重要;} ng :表单{显示:块;}.ng-animate-shim { visibility :隐藏;}.ng-anchor {位置:绝对;}/style meta charset=' UTF-8 ' title angularjs动态生成差异的ID/title脚本src=' http :http://apps。bdimg。com/libs/angular。js/1。4 .6/棱角分明。量滴js '/script脚本var app=angular。模块(' idApp ',[]);app.controller('idCon ',函数($ scope){ $ scope。divides=[{ divided : '图表id 1 ' },{ divided : '图表Id2 ' },{ divided : '图表Id3 ' },{ divided : '图表Id4 ' },{ divided : '图表id 5 ' }];});/script/head body ng-controller=' idCon ' ng-app=' idApp ' class=' ng-scope '!-ngre peat : divides中的图表-div ng-repeat=' divides '中的图表class=' ng-scope ' div id=' ChartID 1 ' class=' ng-binding ' ChartID 1/div/div!-end Ngreepat:设备中的图表-div ng-repeat=' divides '中的图表class=' ng-scope ' div id=' ChartID 2 ' class=' ng-binding ' ChartID 2/div/div!-end Ngreepat:设备中的图表-div ng-repeat=' divides '中的图表class=' ng-scope ' div id=' ChartID 3 ' class=' ng-binding ' ChartID 3/div/div!-end Ngreepat:设备中的图表-div ng-repeat=' divides '中的图表class=' ng-scope ' div id=' ChartId 4 ' class=' ng-binding ' ChartId 4/div/div!-end Ngreepat:设备中的图表-div ng-repeat=' divides '中的图表class=' ng-scope ' div id=' ChartID 5 ' class=' ng-binding ' ChartID 5/div/div!-以分隔线/正文/html格式结束ngRepeat:图表
以上所述是小编给大家介绍的AngularJS动态生成差异的身份源码解析,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!