Importing a controller into an HTML file

I have a file controller.js

and I need to use it in my HTML file, but the moment I make a GET request , I have no 404 not found.
I have no idea why this is happening. Directory:
.. /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");
        });
    };
});

      

+3


source to share


2 answers


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



0


source


The HTML file is inserted into the app.vm file ( Apache Velocity ) and this folder template is different.
You have to inject controller.js in the static folder responsible for the vm file

.. /resources/static/js/controller.js
../resources/templates/app.vm



0


source







All Articles