2016-11-07 99 views
1

我有两个问题:呼叫功能和填充表angularjs

  1. 我不知道如何调用使用angularJS在HTML页面的Java类的功能。

  2. 我需要使用按钮后禁用它。

我的地址是:http://localhost:8080/CreditCardWEB/rest/cc/init

我在我的课有这样:

CardBean.java

@GET 
@Path("/init") 
public void init() { 
    Student s = new Student(1, "Pera", "Peric"); 
    em.persist(s); 
    s = new Student(2, "Pera2", "Peric2"); 
    em.persist(s); 
    s = new Student(3, "Pera3", "Peric3"); 
    em.persist(s); 
} 

在我indexStud.html页,我有一个按钮:

<button ng-click="initStud()">Init Student</button> 

在我controllers.js我有问题,但我不知道如何做到这一点:

$scope.initStud = function() { 
    //call the function from Cardbean.java 
    //disable the button after he is used 
} 

回答

0

好吧,我找到了答案,第1题....这里是

 $scope.initStud = function() { 
      $http.post('http://localhost:8080/CreditCardWEB/rest/cc/init').success(
      function(data) { 
      }); 
} 

这就是在controllers.js文件中需要的 和Cardbean.java文件第一行中的@GET必须更改为@POST