javascript: coordinating angular to recieve data from node.jsHow do I remove a property from a JavaScript object?Remove empty elements from an array in JavascriptConvert form data to JavaScript object with jQueryHow do I remove a key from a JavaScript object?How to process POST data in Node.js?How do I remove a particular element from an array in JavaScript?In Node.js, how do I “include” functions from my other files?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)Node.js create folder or use existingjavascript integrate angular frontend with existing website/project

Multiplicative persistence

Is it improper etiquette to ask your opponent what his/her rating is before the game?

How can "mimic phobia" be cured or prevented?

Aragorn's "guise" in the Orthanc Stone

Redundant comparison & "if" before assignment

Is aluminum electrical wire used on aircraft?

What should you do when eye contact makes your subordinate uncomfortable?

What percentage of fillings performed today are done with mercury amalgam?

How can I block email signup overlays or javascript popups in Safari?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

Loading commands from file

Is the U.S. Code copyrighted by the Government?

How much character growth crosses the line into breaking the character

Yosemite Fire Rings - What to Expect?

The screen of my macbook suddenly broken down how can I do to recover

Store Credit Card Information in Password Manager?

The IT department bottlenecks progress. How should I handle this?

If infinitesimal transformations commute why dont the generators of the Lorentz group commute?

Is this toilet slogan correct usage of the English language?

Did Swami Prabhupada reject Advaita?

Pre-modern battle - command it, or fight in it?

How could a planet have erratic days?

Why is it that I can sometimes guess the next note?

When were female captains banned from Starfleet?



javascript: coordinating angular to recieve data from node.js


How do I remove a property from a JavaScript object?Remove empty elements from an array in JavascriptConvert form data to JavaScript object with jQueryHow do I remove a key from a JavaScript object?How to process POST data in Node.js?How do I remove a particular element from an array in JavaScript?In Node.js, how do I “include” functions from my other files?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)Node.js create folder or use existingjavascript integrate angular frontend with existing website/project













0















I have a project which is currently running on express.js, but i want to add angular to the project to handle the front end thereby making it a single page application, the website currently reloads the whole content from the server when a link is clicked thus redoing what has already been done. So I was hoping to make angular load all the website and only the part which is needed can be provided by the server.



I have the css, js, images etc in a public folder, while the html(using templating engine) is inside the views folder.



The current way things are done is when a route is called the data which belongs to that page(e.g. info, forms, images etc) is loaded via the route into the view then everything would be loaded from the views folder but I am looking at a better way of only sending the information that is needed and not sending the whole site content (kind of).



The routes are all determined in node.js angular may not even know what links would exist until at run time, angular would basically receive the links from node.js at run time.



Please how can I achieve this.



Note: angular is just a add-on existing and main work is on node










share|improve this question


























    0















    I have a project which is currently running on express.js, but i want to add angular to the project to handle the front end thereby making it a single page application, the website currently reloads the whole content from the server when a link is clicked thus redoing what has already been done. So I was hoping to make angular load all the website and only the part which is needed can be provided by the server.



    I have the css, js, images etc in a public folder, while the html(using templating engine) is inside the views folder.



    The current way things are done is when a route is called the data which belongs to that page(e.g. info, forms, images etc) is loaded via the route into the view then everything would be loaded from the views folder but I am looking at a better way of only sending the information that is needed and not sending the whole site content (kind of).



    The routes are all determined in node.js angular may not even know what links would exist until at run time, angular would basically receive the links from node.js at run time.



    Please how can I achieve this.



    Note: angular is just a add-on existing and main work is on node










    share|improve this question
























      0












      0








      0








      I have a project which is currently running on express.js, but i want to add angular to the project to handle the front end thereby making it a single page application, the website currently reloads the whole content from the server when a link is clicked thus redoing what has already been done. So I was hoping to make angular load all the website and only the part which is needed can be provided by the server.



      I have the css, js, images etc in a public folder, while the html(using templating engine) is inside the views folder.



      The current way things are done is when a route is called the data which belongs to that page(e.g. info, forms, images etc) is loaded via the route into the view then everything would be loaded from the views folder but I am looking at a better way of only sending the information that is needed and not sending the whole site content (kind of).



      The routes are all determined in node.js angular may not even know what links would exist until at run time, angular would basically receive the links from node.js at run time.



      Please how can I achieve this.



      Note: angular is just a add-on existing and main work is on node










      share|improve this question














      I have a project which is currently running on express.js, but i want to add angular to the project to handle the front end thereby making it a single page application, the website currently reloads the whole content from the server when a link is clicked thus redoing what has already been done. So I was hoping to make angular load all the website and only the part which is needed can be provided by the server.



      I have the css, js, images etc in a public folder, while the html(using templating engine) is inside the views folder.



      The current way things are done is when a route is called the data which belongs to that page(e.g. info, forms, images etc) is loaded via the route into the view then everything would be loaded from the views folder but I am looking at a better way of only sending the information that is needed and not sending the whole site content (kind of).



      The routes are all determined in node.js angular may not even know what links would exist until at run time, angular would basically receive the links from node.js at run time.



      Please how can I achieve this.



      Note: angular is just a add-on existing and main work is on node







      javascript node.js angular






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      S MevS Mev

      377




      377






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Without any code the answer is going to be quite abstract but here are the main steps that you need to do:



          1. You will need to setup the express.static middleware so that the express app will serve your angular app (typically index.html) and the images:

          app.use(express.static('public')) //images in here



          app.use(express.static('dist')) //index.html in here



          For this to work you will need to specify the --output-path option during ng build:



          ng build --output-path ./dist



          Also, note that each angular components has its own style-sheet. So you will either have to move those .css styles you defined in each component's stylesheet or add them in the angular.json file under the styles array:



          "styles": [
          "styles.css",
          ],


          2. Modify your express app to only serve the index.html file. Everything else will be handled by the API router which will only serve data to the angular app:



          // Set our api routes
          app.use('/api', api);

          // Catch all other routes and return the index file
          app.get('*', (req, res) =>
          res.sendFile(path.join(__dirname, 'dist/index.html'));
          );


          1. You will need to setup the Angular router to handle the navigation between components. This will be specific to your project structure but there are plenty of tutorials out there to help you set it up.

          Let me know if you need any further clarifications.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281208%2fjavascript-coordinating-angular-to-recieve-data-from-node-js%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Without any code the answer is going to be quite abstract but here are the main steps that you need to do:



            1. You will need to setup the express.static middleware so that the express app will serve your angular app (typically index.html) and the images:

            app.use(express.static('public')) //images in here



            app.use(express.static('dist')) //index.html in here



            For this to work you will need to specify the --output-path option during ng build:



            ng build --output-path ./dist



            Also, note that each angular components has its own style-sheet. So you will either have to move those .css styles you defined in each component's stylesheet or add them in the angular.json file under the styles array:



            "styles": [
            "styles.css",
            ],


            2. Modify your express app to only serve the index.html file. Everything else will be handled by the API router which will only serve data to the angular app:



            // Set our api routes
            app.use('/api', api);

            // Catch all other routes and return the index file
            app.get('*', (req, res) =>
            res.sendFile(path.join(__dirname, 'dist/index.html'));
            );


            1. You will need to setup the Angular router to handle the navigation between components. This will be specific to your project structure but there are plenty of tutorials out there to help you set it up.

            Let me know if you need any further clarifications.






            share|improve this answer



























              0














              Without any code the answer is going to be quite abstract but here are the main steps that you need to do:



              1. You will need to setup the express.static middleware so that the express app will serve your angular app (typically index.html) and the images:

              app.use(express.static('public')) //images in here



              app.use(express.static('dist')) //index.html in here



              For this to work you will need to specify the --output-path option during ng build:



              ng build --output-path ./dist



              Also, note that each angular components has its own style-sheet. So you will either have to move those .css styles you defined in each component's stylesheet or add them in the angular.json file under the styles array:



              "styles": [
              "styles.css",
              ],


              2. Modify your express app to only serve the index.html file. Everything else will be handled by the API router which will only serve data to the angular app:



              // Set our api routes
              app.use('/api', api);

              // Catch all other routes and return the index file
              app.get('*', (req, res) =>
              res.sendFile(path.join(__dirname, 'dist/index.html'));
              );


              1. You will need to setup the Angular router to handle the navigation between components. This will be specific to your project structure but there are plenty of tutorials out there to help you set it up.

              Let me know if you need any further clarifications.






              share|improve this answer

























                0












                0








                0







                Without any code the answer is going to be quite abstract but here are the main steps that you need to do:



                1. You will need to setup the express.static middleware so that the express app will serve your angular app (typically index.html) and the images:

                app.use(express.static('public')) //images in here



                app.use(express.static('dist')) //index.html in here



                For this to work you will need to specify the --output-path option during ng build:



                ng build --output-path ./dist



                Also, note that each angular components has its own style-sheet. So you will either have to move those .css styles you defined in each component's stylesheet or add them in the angular.json file under the styles array:



                "styles": [
                "styles.css",
                ],


                2. Modify your express app to only serve the index.html file. Everything else will be handled by the API router which will only serve data to the angular app:



                // Set our api routes
                app.use('/api', api);

                // Catch all other routes and return the index file
                app.get('*', (req, res) =>
                res.sendFile(path.join(__dirname, 'dist/index.html'));
                );


                1. You will need to setup the Angular router to handle the navigation between components. This will be specific to your project structure but there are plenty of tutorials out there to help you set it up.

                Let me know if you need any further clarifications.






                share|improve this answer













                Without any code the answer is going to be quite abstract but here are the main steps that you need to do:



                1. You will need to setup the express.static middleware so that the express app will serve your angular app (typically index.html) and the images:

                app.use(express.static('public')) //images in here



                app.use(express.static('dist')) //index.html in here



                For this to work you will need to specify the --output-path option during ng build:



                ng build --output-path ./dist



                Also, note that each angular components has its own style-sheet. So you will either have to move those .css styles you defined in each component's stylesheet or add them in the angular.json file under the styles array:



                "styles": [
                "styles.css",
                ],


                2. Modify your express app to only serve the index.html file. Everything else will be handled by the API router which will only serve data to the angular app:



                // Set our api routes
                app.use('/api', api);

                // Catch all other routes and return the index file
                app.get('*', (req, res) =>
                res.sendFile(path.join(__dirname, 'dist/index.html'));
                );


                1. You will need to setup the Angular router to handle the navigation between components. This will be specific to your project structure but there are plenty of tutorials out there to help you set it up.

                Let me know if you need any further clarifications.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                MrfksIVMrfksIV

                16511




                16511





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281208%2fjavascript-coordinating-angular-to-recieve-data-from-node-js%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript