0

I've tried to find solution for my problem since 3 days and so far I have nothing. I'm trying to build web application for chatting. My problem is that I have no idea how to use method from Java Object in AngularJS. I've tried to pass object from class that stores it with SpringMVC

model.addAttribute("name", object);

and then use it like that:

<div ng-app="sendMessage" ng-controller="msgController" style="text-align: left; margin-left: 10vw;">
            <input type="text" ng-model="message" style="width: 80vw;">
            <button type="submit" ng-click="sendMsg(${name})">Send</button>
</div>

and in script:

<script>
    var app = angular.module('sendMessage', []);
    app.controller('msgController', function($scope) {
    $scope.sendMsg = function(messages) {
        var currentTime = new Date();
        messages.sendMessage('user', $scope.message, currentTime);
        };
    });
</script>

And this is beggining of my *.jsp file:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Chat</title>
    </head>

I'm not sure if that's correct way. Can't answer that because when I've tried it I found another problem. When I test code on web html/AngularJS builders everything is working (except with my Java objects because they aren't there) but when I build my app and deploy it on weblogic even basic AngularJS functions ain't working (e.g. using $scope.variable = 'something' in app.controller for {{variable}}). I'm using Java 6, Eclipse for Java EE and WebLogic 10.3.6.

Kamil Przybyo
  • 115
  • 1
  • 8

0 Answers0