3

I have a file controller.js and I need use in my HTML file but in the moment I make a GET request I have 404 not found.
I have no ideia why this happens. The directory is:
../resources/js/controller.js
../resources/templates/app.vm

enter image description here

HTML

<!DOCTYPE html>
<html ng-app="oknok">
<head lang="pt-br">
    <meta charset="UTF-8"/>
    <title>OKNOK Admin</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script>
    <script src="../js/controller.js"></script>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>

<body ng-controller="controller">
<center>
    <h1>Cadastro de veículos</h1>
    <div class="col-xs-4">
        <label for="nome">Nome:</label>
        <input type="text" class="form-control" ng-model="nome"><br>
        <label for="tipo">Tipo:</label>
        <input type="text" class="form-control" ng-model="tipo"><br>
        <button type="button" class="btn btn-success" ng-model="salvar" ng-click="salvar()">Salvar</button>
    </div>
</center>
</body>
</html>

JS

var oknok = angular.module('oknok', []);

oknok.controller('controller', function ($scope, $http) {
    console.log("1");
    $scope.salvar = function () {
        console.log("entrou");
        $http.post("/veiculos", {
            msg: "teste"
        }).success(function(data, status, headers, config){
            console.log("enviado com sucesso");
        }).error(function(data, status, headers, config){
          console.log("erro ao enviar");
        });
    };
});
Stepan Suvorov
  • 25,118
  • 26
  • 108
  • 176
Daniela Morais
  • 2,125
  • 7
  • 28
  • 49

2 Answers2

0

Try <script src="/resources/js/controller.js"></script>

JDrost1818
  • 1,116
  • 1
  • 6
  • 23
0

The HTML file is inserted into the app.vm file (Apache Velocity) and it's folder pattern is different.
You must enter controller.js within the static folder responsible for vm file
../resources/static/js/controller.js
../resources/templates/app.vm

Daniela Morais
  • 2,125
  • 7
  • 28
  • 49