客户端模板,每个角色视图 [英] Client Side Template with view per role

查看:105
本文介绍了客户端模板,每个角色视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 AngularJS ,它似乎非常有前途,我想的唯一的事情搞清楚,不特定的框架,但它的总体客户端 - 侧模板。

I've been reading about AngularJS and it seems very promising, the only thing I'm trying to figure out, not specific for framework, but it's general for client-side template.

假设你有多个角色的Web应用程序,每个角色可能包含除了功能,,,这样你就可以不必为每个角色不同的模板,那会被认为是不好的做法,所以我的问题是,什么是用最好的方法在此期间客户端模板,而不是暴露你的模板客户,因此,例如,在 AngularJS 我没有使用 NG-显示?什么最好的工具,在服务器端生成模板?

Let's say you have a web application with multiple roles, each role may contain addition feature,,, so you cannot have different template for each role, that would be considered bad practice, so my question is what's the best approach to use client-side template in the mean time, not exposing your template to client, so for example, in AngularJS I don't have to use ng-show? What best tool to generate template at server side?

推荐答案

Blesh大约只向用户提供的数据与服务器端的适当作用正确的,但它听起来像你想重新使用您的客户端UI件

Blesh is correct about only providing data to users with the appropriate role on the server side, but it sounds like you want to re-use pieces of your client UI.

在AngularJS,你可以使用 NG-包括,并建立不同的谐音为不同的数据块。所以,你可以写这样的事情都在你的医生和护士的观点:

In AngularJS, you could use ng-include and build up different partials for different pieces of data. So you could write something like this in both your "doctor" and "nurse" views:

<div ng-include="'allergies.html'"></div>

再有一个叫做一个单独的HTML文件 allergies.html

<p>Allergy info: {{someData}}</p>

另一种选择是使用指令

Another option would be to use directives.

这篇关于客户端模板,每个角色视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆