One controller, divergent template, introducing a fresh variable

I have a webpage where I showcase data (www.mysite.com/:gameId). In order to create a printer-friendly version of this data, I've set up a print page at www.mysite.com/:gameId/print. Both pages display the same information but with different designs. My goal is to hide the main header and footer when the user accesses the print page by using ng-show. How can I ensure that ng-show=false is called when the print page loads?

Currently, I have the following setup, however, it's not working as expected despite trying various controllers. The Print controller has the code "$rootScope.hide_for_print = false;".


        .when('/:gameId', {
            controller: 'game',
            templateUrl: 'views/gamePage.html'
        })

        .when('/:gameId/print', {
            controller: 'game, print',
            templateUrl: 'views/gamePrint.html'
        })
    

Answer №1

To ensure the print option is included in the route, make the following adjustment:

 .when('/:gameId/:print', {
    controller: 'game',
    templateUrl: 'views/gamePrint.html'
});

Additionally, remember to inject $routeParams into your controller and set the appropriate flag:

  $scope.hide_for_print = $routeParams.print; 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to retrieve information from a JSON string?

I am currently receiving a JSON object from the backend and I only need the "result" array in my Angular application template variable. { "result":[ {"name":"Sunil Sahu", "mobile":"1234567890", "emai ...

Is there a built-in method called router.reload in vue-router?

Upon reviewing this pull request: The addition of a router.reload() method is proposed. This would enable reloading with the current path and triggering the data hook again. However, when attempting to execute the command below from a Vue component: th ...

Posting several pictures with Protractor

In my test suite, I have a specific scenario that requires the following steps: Click on a button. Upload an image from a specified directory. Wait for 15 seconds Repeat Steps 1-3 for all images in the specified directory. I need to figure out how to up ...

Incorporate an assortment of facial features into BufferGeometry using three.js

If I have a BufferGeometry, I can easily assign its vertices using an array of type Float32Array with the following code snippet: geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); However, is there a way to set the f ...

Invoke a separate function after a successful Ajax request

I am currently working on an AJAX call in MVC3 and here is the snippet of code I have: save: function () { $.ajax({ url: "@Url.Action("Save")", type:"post", data: ko.toJSON(this), contentType:"applic ...

The number of articles in the MongoDB database is currently unknown

Currently, I am in the process of developing a blog using nodejs, express, and mongodb with jade as the template engine. The folder structure of my project looks like this: project/ modules/ views/ index.jade app. ...

Utilizing Angular JS to Manage Controller Events

I am currently working on an application that requires saving a large amount of data in cascade, similar to a typical master-detail view. Within this view, there is a "Save All" Button which saves each row in an iteration. This process triggers jQuery cus ...

Cypress - Mastering negative lookaheads in Regular Expressions

While experimenting with Cypress, I encountered an issue regarding a filter test. The goal is to verify that once the filter is removed, the search results should display values that were filtered out earlier. My attempt to achieve this scenario involves ...

Converting Microsoft Word files into HTML format

Similar Question: Converting .doc to html using PHP I'm looking for a way to transform a word document into HTML format for embedding on a webpage. I'd like to accomplish this task using PHP. Any suggestions on how to achieve this? ...

How can I effectively monitor and track modifications to a document's properties in MongoDB?

I'm wondering how to effectively track the values of a document in MongoDB. This involves a MongoDB Database with a Node and Express backend. For example, let's say there is a document within the Patients collection: { "_id": "4k2lK49938d ...

Installing v8-profiler on Windows 8 (64 bit) through npm: a step-by-step guide

The v8-profiler module is widely recognized as the go-to tool for identifying memory leaks in node.js applications. However, attempting to install it with npm install v8-profiler results in an error message related to compatibility issues between 32bit an ...

AngularJS doesn't cooperate well with square brackets in form field names

While using AngularJS for validation within a Symfony2 form, I encountered an issue with the naming of the form field generated by Symfony2 as "license[domain]". The validation process functions correctly; however, AngularJS struggles to handle the braces ...

Utilizing nodejs to interact with a web service

Recently diving into Node.js and currently exploring how to utilize services with NodeJS. Seeking guidance on the NodeJS equivalent of the code snippet provided below: $.ajax({ type: "POST", url: "/WebServiceUtility.aspx/CustomOrderService", data: " ...

Encountering a "Error 404: Page Not Found" message when trying to request a json object from a node server

Working on a RESTful API, I have set it up to run on node.js using express.js, mongodb with mongoose for object modeling, and body-parser for passing HTTP data. However, whenever I start the server and try to access the specified IP address, I encounter a ...

A step-by-step guide on integrating the CSS file of react-datepicker into a Nestjs SSR application with AdminJS

Currently, I am integrating the react-datepicker component into my SSR project built with Nest.js and Admin.js. To ensure that the React components function properly and are styled correctly, I need to include the line 'import 'react-datepicker/d ...

Implementing Canvas Offset in a jQuery Mobile Environment

I have positioned a pen ready for use at this location. http://codepen.io/prantikv/pen/LEbRKY Currently, I am utilizing a canvas to track mouse movements or touch input. It performs as expected when jQuery or jQuery mobile is not included. However, upon ...

What options do I have for sorting through my inventory using the search feature?

Having some trouble setting up isotope filtering on my search bar. I have managed to get the Isotope function working on checkboxes, but for some reason, my search bar isn't functioning as expected. I found a solution online for filtering results bas ...

Incorporate Bookmarklet into GitHub README.md

Trying to add a Bookmarklet to a Github README.md, but encountering issues with the markdown code: [Bookmarklet](javascript:alert('not-working')) It appears that the javascript in the link is being stripped out from the compiled output. Is this ...

Create a compass application using React-Native

I am attempting to create a compass, but I am unsure how to utilize the Magnetometer data. Below is my Compass class: class Compass extends Component { constructor(props) { super(props); } componentWillMount(){ this._animeRotation = new Ani ...

Ways to ensure the title changer works seamlessly for everyone

Having a title changer for elements visible in the viewport is crucial. However, the current setup only works for a single division and fails to function with multiple divisions. Click Here for Live Testing and Viewing Check out the jsFiddle for Code V ...