AngularJS 和 Java EE 集成 AngularBeans

码农软件 · 软件分类 · AngularJS 扩展 · 2019-03-16 22:11:39

软件介绍

Angular Beans 是一个使用 Java EE 7 和 CDI 规范轻松实现在 Java EE 应用中集成 AngularJS 框架的功能。

特性:

  • 可以在 CDI Bean 注入和回调 AngularJS 服务

  • 将 $scope 绑定到 Bean 模型

  • 处理 HTTP 方法调用

  • 最好的控制服务端和客户端的数据更新

  • 可通过 WebSocket 和 SockJS 集成来处理实时的调用

  • queryModels: 查询服务器数据并根据模型更新客户端显示

  • 事件和 queryModels 广播

  • Angular 表单验证,基于 Bean Validation 注解

  • 内建 I18n 翻译

  • 时间驱动、实时和轻量级

示例应用:

HelloBean.java

package helloWorld;

import angularBeans.api.AngularBean;
import angularBeans.api.NGReturn;
import angularBeans.realtime.RealTime;

import java.io.Serializable;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;

@AngularBean
@RequestScoped
public class HelloBean implements Serializable {
    
    @GET
    public String sayHello(String name) {
        return "hello " + name;
    }
}

app.js

'use strict';

angular.module('myModule', [ 'angularBeans' ]);

angular.module('myModule')
.controller('HelloCtrl', function($scope, helloBean) {


    $scope.sayHello = function(name) {
        helloBean.sayHello(name).then(function(result){
            $scope.result=result;    
        }
        );
    }

});

hello.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">

<script type="text/javascript" src="angular/angular.min.js"></script>
<script type="text/javascript" src="sockjs/sockjs.min.js"></script>
<script type="text/javascript" src="angular-beans.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>

<body ng-app="myModule">
    <div ng-controller="HelloCtrl">
        <label>your name :</label> <input type="text" ng-model="name" />
        <button ng-click="sayHello(name)">sayHello</button>
        {{result}}
    </div>
</body>
</html>

运行结果:

本文地址:https://codercto.com/soft/d/1508.html

Design and Analysis of Distributed Algorithms (Wiley Series on P

Design and Analysis of Distributed Algorithms (Wiley Series on P

Nicola Santoro / Wiley-Interscience / 2006-10-27 / USD 140.95

This text is based on a simple and fully reactive computational model that allows for intuitive comprehension and logical designs. The principles and techniques presented can be applied to any distrib......一起来看看 《Design and Analysis of Distributed Algorithms (Wiley Series on P》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具