{"action":"created","issue":{"url":"https://api.github.com/repos/xufei/blog/issues/34","repository_url":"https://api.github.com/repos/xufei/blog","labels_url":"https://api.github.com/repos/xufei/blog/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/xufei/blog/issues/34/comments","events_url":"https://api.github.com/repos/xufei/blog/issues/34/events","html_url":"https://github.com/xufei/blog/issues/34","id":149633953,"number":34,"title":"xufei大神，冒昧的开个issue问个我很想知道的问题，谢谢~~~","user":{"login":"yalishizhude","id":3870098,"avatar_url":"https://avatars.githubusercontent.com/u/3870098?v=3","gravatar_id":"","url":"https://api.github.com/users/yalishizhude","html_url":"https://github.com/yalishizhude","followers_url":"https://api.github.com/users/yalishizhude/followers","following_url":"https://api.github.com/users/yalishizhude/following{/other_user}","gists_url":"https://api.github.com/users/yalishizhude/gists{/gist_id}","starred_url":"https://api.github.com/users/yalishizhude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yalishizhude/subscriptions","organizations_url":"https://api.github.com/users/yalishizhude/orgs","repos_url":"https://api.github.com/users/yalishizhude/repos","events_url":"https://api.github.com/users/yalishizhude/events{/privacy}","received_events_url":"https://api.github.com/users/yalishizhude/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-04-20T02:07:51Z","updated_at":"2016-04-20T11:01:18Z","closed_at":null,"body":"使用Angular有一年时间了，今年开始使用node.js的时候，发现angular的指令和双向数据绑定和后端的数据模板技术有冲突。举个例子：\r\n有一个可操作的表格，我想在node.js端用模板生成，但是这样的话浏览器端就脱离了$scope作用域，controller就不好操作了。所以现在涉及到用户交互的指令我都不得不额外发ajax请求，然后由$scope来填充模板，降低了性能。\r\n所以我的问题是：**有没有办法由后端模板填充数据生成页面后，同时angular在浏览器端可以对其进行数据绑定？**\r\n\r\n```\r\n//后端模板填充\r\n{{#list people}}\r\n<tr>...</tr>\r\n{{/list}}\r\n```\r\n\r\n```\r\n//为了数据绑定，我只能通过angular在浏览器端这么写\r\n<tr ng-repeat=\" p in people\">\r\n...\r\n</tr>\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/xufei/blog/issues/comments/212380553","html_url":"https://github.com/xufei/blog/issues/34#issuecomment-212380553","issue_url":"https://api.github.com/repos/xufei/blog/issues/34","id":212380553,"user":{"login":"KingMario","id":3956876,"avatar_url":"https://avatars.githubusercontent.com/u/3956876?v=3","gravatar_id":"","url":"https://api.github.com/users/KingMario","html_url":"https://github.com/KingMario","followers_url":"https://api.github.com/users/KingMario/followers","following_url":"https://api.github.com/users/KingMario/following{/other_user}","gists_url":"https://api.github.com/users/KingMario/gists{/gist_id}","starred_url":"https://api.github.com/users/KingMario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KingMario/subscriptions","organizations_url":"https://api.github.com/users/KingMario/orgs","repos_url":"https://api.github.com/users/KingMario/repos","events_url":"https://api.github.com/users/KingMario/events{/privacy}","received_events_url":"https://api.github.com/users/KingMario/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T11:01:18Z","updated_at":"2016-04-20T11:01:18Z","body":"> 这样插一堆的script标签一方面不符合w3c的行为、样式、结构分离的规范，另一方面维护性也是很差的。\r\n\r\n看不出来会违反什么规范。再说还有ng-init啊。\r\n\r\n关于性能方面，个人觉得比较“把占绝大部分的静态内容缓存”和“每次都全页刷新”，网络开销方面的性能优劣是不言而喻的，至于浏览器渲染的影响，由于上述网络开销方面的差异，可能与此正好相抵销。如果还存在差别，可以用一些“花招”来让用户在体验上感觉不明显。\r\n\r\n> 感觉angular的指令就是一个前端模板，angular错误确实不太好查找。后端模板在不添加过多逻辑的情况下还是可以维护的，模板引擎编译的时候也会报错。排版的问题可以用插件解决的~   \r\n\r\n你可以把加angular指令的html语句看作是模板，不过和其他使用花括号并且有“开门”、“关门”的模板相比，对于复杂的控制结构，这种“模板”犯错的机会大大减少了。\r\n"}}