Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JSNI使用angularjs在gwt中创建示例演示?_Angularjs_Gwt_Jsni - Fatal编程技术网

如何使用JSNI使用angularjs在gwt中创建示例演示?

如何使用JSNI使用angularjs在gwt中创建示例演示?,angularjs,gwt,jsni,Angularjs,Gwt,Jsni,我已经创建了一个示例演示应用程序,其中包含以下html页面 <!doctype html> <!-- The DOCTYPE declaration above will set the --> <!-- browser's rendering engine into --> <!-- "Standards Mode". Replacing this declaration --> <!-- with

我已经创建了一个示例演示应用程序,其中包含以下html页面

<!doctype html>
<!-- The DOCTYPE declaration above will set the     -->
<!-- browser's rendering engine into                -->
<!-- "Standards Mode". Replacing this declaration   -->
<!-- with a "Quirks Mode" doctype is not supported. -->

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script>
function alert1(p1) {
    alert("P1 is "+p1);             
}
</script>
    <!--                                                               -->
    <!-- Consider inlining CSS to reduce the number of requested files -->
    <!--                                                               -->
    <link type="text/css" rel="stylesheet" href="Sample_JS.css">

    <!--                                           -->
    <!-- Any title is fine                         -->
    <!--                                           -->
    <title>Web Application Starter Project</title>

    <!--                                           -->
    <!-- This script loads your compiled module.   -->
    <!-- If you add any GWT meta tags, they must   -->
    <!-- be added before this line.                -->
    <!--                                           -->
    <script type="text/javascript" language="javascript" src="sample_js/sample_js.nocache.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

    <script type="text/javascript">

        var app = angular.module('MyApp', [])
        app.controller('MyController', function ($scope, $window) {

            $scope.nameList = [];
            $scope.ShowAlert = function () {

                $scope.nameList.push($scope.nameFieldContainer);
                $window.alert("Hello  Angular : "+$scope.nameFieldContainer);
            }
        });
    </script>


  </head>

  <!--                                           -->
  <!-- The body can have arbitrary html, or      -->
  <!-- you can leave the body empty if you want  -->
  <!-- to create a completely dynamic UI.        -->
  <!--                                           -->
  <body>

    <!-- OPTIONAL: include this if you want history support -->
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

    <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>



     <div ng-app="MyApp" ng-controller="MyController">

        <h1>Web Application Starter Project</h1>

        <table align="center">
            <tr>
                <td colspan="2" style="font-weight:bold;">Please enter your name:</td>        
            </tr>
            <tr>
                <td data-ng-model="nameFieldContainer" id="nameFieldContainer"></td>
                <td id="test" ></td>
                <td id="sendButtonContainer" ng-click="ShowAlert()"></td>
            </tr>
            <tr>
                <td> <input type ="text" data-ng-model="nameFieldContainer"> </td>
                <td colspan="2" style="color:red;" id="errorLabelContainer"></td>
            </tr>
            <tr>
                <td><input type = "button" name="click" ng-click="ShowAlert()"></td>
            </tr>

        </table>

        <table align="center">
            <tr ng-repeat = "name in nameList">
                <td colspan="2" style="font-weight:bold;">{{name}}</td>        
            </tr>

        </table>

    </div>

  </body>
</html>
我试图使用gwt按钮组件从下面的原生js方法调用anularjs函数,但我不能

package com.google.client;

public class MyTestJS {

    public static native boolean hasPopupBlocker(String name)/*-{
        if (!name){
            name = "Please enter name";
        }else{
            name = "Hello  "+ name ;
        }
        return $wnd.ShowAlert();
    }-*/;
}
如何从gwt调用angularJs ShowAlert()函数(通过单击java代码中的按钮或其他方式)? 请建议。 任何帮助都是值得的。。。。。。
提前谢谢。

你查过谷歌了吗?远处,有一座gwt ng大桥正在建造中:看这里:
package com.google.client;

public class MyTestJS {

    public static native boolean hasPopupBlocker(String name)/*-{
        if (!name){
            name = "Please enter name";
        }else{
            name = "Hello  "+ name ;
        }
        return $wnd.ShowAlert();
    }-*/;
}