Angular.js(net :: ERR_ABORTED 404(未找到))

时间:2019-03-20 20:50:55

标签: node.js angularjs express

我的服务器配置文件

  const express=require('express');
const app = express();
const logger=require('./utils/logger');
const bodyParser=require('body-parser');

app.use(express.static('public'));
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.set("view engine","ejs");
app.use('/', require('./Routes/sellerRoutes'));
app.listen(process.env.PORT||1234, (err)=>{

    if(err) {
        console.log('An Error has occured', err);
        logger.error('Server Not Start ',err);
    }

    else {

        console.log("Server Started");
        logger.debug('Server Started');
    }
})

我的路由文件

const seller=require('express').Router();
const logger=require('../utils/logger');
const adminUser=require('../Models/Userclass');
const password=require('../Models/Passchange');
const operations=require('../db/Helpers/sellerOperations');

seller.post('/change',(req,res)=>{

    console.log('kkkkkkkkkkkkkk');
    res.render('change');
    var newPass=req.body.newPass;
    console.log("New Password:::",newPass);
    var confirmPass=req.body.confirmPass;
    console.log('Confirm Password:::',confirmPass);   
    var passPanel=new password(newPass,confirmPass);
    var pr=operations.findOneAndUpdate(passPanel);

    pr.then(data=>{
        console.log(data);
        res.render('change',{newPass:data.newPass, confirmPass:data.confirmPass});

    })
})


seller.post('/submit',(req,res)=>{
   res.render('submit');
});
module.exports=seller;

MY ejs(模板引擎)文件

<body class="section">
    <h1><center>Password Change</center></h1>
    <form method="POST" action="submit">
        <% var newPass;%> <% var confirmPass; %>
        <label for="">New Password:</label>
        <input type="password" id="newPass" name="newPass" value="<%=newPass%>">

    <div class="cnfrm">
        <label for="">Confirm Password:</label>
        <input type="password" id="confirmPass" name="confirmPass" value="<%=confirmPass%>">
    </div>
        <button id="chngepswd" class="btn btn-success">OK</button></a>
    </form>
    <br>
</body>

我的Controller.js文件

const app=angular.module('app', []);
app.controller('adminctrl', ($scope,$http,$q)=>{
    var newPass=$scope.newPass;
    var confirmPass=$scope.confirmPass;

$scope.dochange()=function(){
    $http.post('http://localhost:1234/user').then((data)=>{

        let defered = $q.defer();
        console.log(data);
        defered.resolve(data);

    }),then((err)=>{
        console.log(err);
        defered.reject(err);
    })

    return defered.promise;
}

})

Index.html文件

<!DOCTYPE html>
<html lang="en" ng-app='app'>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <title>Document</title>
    <script src="../bower_components/angular/angular.min.js"></script>
    <script src="../app.js"></script>
    <script src="../js/controller.js""></script>
</head>
<style>

</style>
<body >
    <div ng-controller="adminctrl">
        <div>
            <label for="">New Password</label>
            <input type="text" name="newPass" id="newPass" ng-model="newPass">{{newPass}}<br>

            <label for="">Confirm Password</label>
            <input type="text" name="confirmPass" id="confirmPass" ng-model="confirmPass">{{confirmPass}}<br>

            <button ng-click="dochange()">OK</button><br>
        </div>
    </div>
    <br>
</body>
</html>

我正在为我的Web应用程序做前端。我在公用文件夹中创建了index.html文件,在js文件夹中创建了一个controller.js文件。我已经在HTML文件的脚本标签中声明了.js文件的来源。

但是,当我加载服务器时,它说找不到控制器,并且我已经安装了bower软件包管理器,并从中安装了angular.js。我的浏览器无法找到其中没有我的(angilar.min.js文件)或controller.js文件的Bower组件。

  

net :: ERR_ABORTED 404(未找到)用于每个文件,甚至是凉亭。

0 个答案:

没有答案