Exploring the scope accessibility within the windowTemplateUrl feature in Angular

My modal has a windowTemplateUrl that looks like this:

<div tabindex="-1" role="dialog" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" data-ng-click="close($event)">
    <div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}">
        <div class="modal-content square-btn">
            <div class="modal-header custom-modal-header square-btn">
                <button type="button" class="close" data-dismiss="modal" ng-click="cancel($event)">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h3 class="modal-title">{{modalTitle}}--</h3>
            </div>
            <div class="modal-body" modal-transclude>

            </div>            
        </div>
    </div>
</div>

Here is my JavaScript code:

$modal.open({
            windowTemplateUrl: 'templates/common/modal.html',            
            templateUrl: 'templates/jobs/create-job-modal.html',
            resolve: {
                modalTitle: function(){
                    return 'Create new position';
                }
            },
            controller: ['$scope', 'modalTitle', function( $scope, modalTitle ) {
                $scope.modalTitle = modalTitle;
            }]
        });

It appears that I can't access my scope from the modal.html template, but I can access it from the create-job-modal.html template. How can I make it accessible in the modal.html template as well? Thank you for your help.

Answer №1

Interestingly, the controller's scope is actually the parent scope of the windowTemplate, which may seem counter-intuitive at first.
To access modalTitle within your windowTemplate, you can simply use $parent.modalTitle.

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

Issues with Displaying Components Generated from an Array in JSX

I have a task variable which has the structure as follows: [ team_id_1: { task_id_1: { description: ... }, task_id_2: { description: ... } }, team_id_2: { ... } ] When trying ...

Conceal hyperlink repeatedly using jQuery

I am struggling with implementing a feature where I have two links, one displayed and the other hidden. Upon clicking the first link, it should disappear and the second link should be displayed. Clicking the second link should then hide itself and show the ...

Execute a jQuery function when the page loads and then trigger it again using buttons

Check out my JSFiddle demonstration here: http://jsfiddle.net/d3fZV/438/ I have a snippet of a slot machine running on a webpage. Currently, it is inactive until the user clicks the button. I am interested in triggering this script on page load or window. ...

What is preventing me from adjusting the width of an image that extends outside of its parent container, even though I am able to modify the height?

I am facing an issue with a div on my website that has specific properties: #viewport{ overflow: hidden; display: block; position: relative; width: 323px; height: 323px; } Embedded within this div is an element with the following prop ...

Breaking apart faces of a sphere using Three.js

I am currently working on creating a sphere geometry. geometry = new THREE.SphereGeometry( 200, 20, 10 ); material = new THREE.MeshLambertMaterial({ shading: THREE.FlatShading, color: 0xff0000 }); sphere = new THREE.Mesh(geometry, material); scene.add( sp ...

What is the best way to send HTML content from a controller using ajax?

Here is the code in my controller: public async Task<ActionResult> GetHtml(int id) { var myModel = await db.Models.FindAsync(id); return Json(new { jsonData = myModel.MyHtml }, JsonRequestBehavior.AllowGet); } This is ...

Exploring the versatility of orderBy and filter in handling cross-referenced content across multiple JSON objects

Is there a way to filter and search for the item name when the item details are sourced from another JSON object? Demo: http://codepen.io/anon/pen/GjAxKX While the rest of the filtering and ordering functionalities are functioning correctly, I am struggl ...

What is the best way to organize an array both alphabetically and by the length of its elements?

Imagine I am working with an array like this: ['a', 'c', 'bb', 'aaa', 'bbb', 'aa']. My goal is to sort it in the following order: aaa, aa, a, bbb, bb, c. this.array= this.array.sort((n1, n2) => ...

Issue with displaying the appropriate x-axis label in ReactJS' ApexCharts

I am currently facing an issue with the label display in percentage on a basic ApexChart. The problem lies in correctly displaying the label as a percentage. Below is the code snippet I am using for the x-axis: xaxis: { labels: { formatter: ...

Utilizing template caching with uibmodal

After spending some time working on my application to make it functional offline, I have successfully cached my templates using $http and templateCache. However, I am facing an issue with $uibmodal that I can't seem to solve in an elegant manner. I ha ...

Customize Column Headers in Handsontable: A Quick Guide

Is there a way to customize the appearance of column headers in handsontable? I have provided a jsfiddle example to showcase my current progress. While I am able to format the first row of data and change the column titles, I am facing difficulty in forma ...

Storing data using angular-file-upload

In my application, I am utilizing the "angular-file-upload" library to save a file. Here is the code snippet that I am using: $scope.submitForm = function(valid, commit, file) { file.upload = Upload.upload({ url: '/tmp', data ...

Utilizing HTML5 to showcase the techniques of character creation in writing

Hello there, I am a newcomer to HTML5 and have a project in mind to showcase how a character is written by hand in the correct order. I currently have this code to generate a Chinese character using canvas. However, I am wondering if there is a way to dra ...

How can we increase the accuracy of numerical values in PHP?

When performing a math operation in JavaScript, the result is: 1913397 / 13.054 = 146575.53240386088 However, when the same operation is performed in PHP, the result is slightly different: 1913397 / 13.054 = 146575.53240386 This discrepancy may be due ...

The Magic of ngModel Formatters and Parsers

I've tried asking the same question in a different way, but unfortunately, no one has answered yet. I'm struggling to grasp the concept of Formatters and Parsers in angular js. On one hand, both the Formatters and Parsers seem quite similar to m ...

Encountering an issue with deploying a nest.js project to Google Firebase Functions

When it comes to programming languages, NestJs utilizes ES6, ES7, and ES8, while Firebase Functions seems to be stuck at Node v.6.11. I made an attempt to create a webpack configuration file with Babel in order to transpile both my files and the node_modu ...

What is the purpose of these specific Javascript expressions (+!)?

Currently, I am attempting to convert JavaScript code into Python. One of the challenges I am facing is understanding the purpose of certain expressions, which has left me feeling stuck. Below is the segment of code that I am trying to translate. va ...

Experiencing a challenge with $http.post in Angular js when using it with node

Despite my server functioning correctly and returning the desired result, I am facing an issue where my angularjs $http.post .then method is not being executed, neither is the .catch method. The node js controller below is responsible for validating if an ...

Error encountered: Setting the XMLHttpRequest responseType to "json" results in a SYNTAX_ERR: DOM Exception 12

I've been encountering an issue while trying to set the XHR responseType to "json". Everything seems to be working fine when I keep it as an empty string xml.responseType = "";. However, once I switch it to "json", I'm hit with the console error ...

Vue - when multiple parents share a common child component

Is there a way in Vue.js for multiple parents to share the same child component? I am looking to have multiple delete buttons trigger a single modal with different content. For example: myfile.html: <table id="app" class="table table-striped table-s ...