"Embrace the powerful combination of WinJS, Angular, and TypeScript for

Currently, I am attempting to integrate winjs with Angular and TypeScript. The Angular-Winjs wrapper functions well, except when additional JavaScript is required for the Dom-Elements.

In my scenario, I am trying to implement the split-view item. Although the menu appears, the JavaScript functionality does not work as expected.

Below is a snippet of the code I am using:

<win-split-view-pane-toggle split-view="splitViewElement"></win-split-view-pane-toggle>
<win-split-view id="splitView">
    <win-split-view-pane>
        SplitView Navigation Pane
        <win-split-view-command label="'Home'" icon="'home'" on-invoked="goToHome()"></win-split-view-command>
        <win-split-view-command label="'Settings'" icon="'settings'" on-invoked="goToSettings()"></win-split-view-command>
    </win-split-view-pane>
    <win-split-view-content>SplitView Content Area</win-split-view-content>
</win-split-view>

This code is sourced from a github project.

Their example mentions that I need to include the following in my Controller:

angular.module("yourAngularApp", ["winjs"]).controller("yourController", function ($scope) {
    $scope.splitViewElement = document.getElementById("splitView");
});

My issue stems from the fact that I am using TypeScript and constructing my Controller utilizing the controllerAs syntax. When I try to add:

$scope.splitViewElement = document.getElementById("splitView");

To my controller, the splitView element returns NULL.

I also attempted:

angular.element("splitView").context 

Although this provides an element, it still does not function correctly.

Here is an excerpt from my Controller:

constructor($scope, $state, $http, $q) {
    super($state, $http, $q, $scope, true);

    $scope.splitViewElement = document.getElementById("splitView"); //this is null
    $scope.splitViewElement = angular.element("splitView").context; //this is not null

}

Answer №1

Although I may be tardy in my response, I wanted to share how I handle this situation. When working with my controller, I utilize angular.element to query for the specific element.

vm.splitViewElement = angular.element("#splitView")[0];

If the element is found, it will likely be the first item in the array. From there, simply bind the vm.splitViewElement to your view:

<win-split-view-pane-toggle class="win-splitviewpanetoggle" split-view="vm.splitViewElement">
</win-split-view-pane-toggle>

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

Transforming a "singular or multiple" array into an array of arrays using TypeScript

What is causing the compilation error in the following code snippet, and how can it be resolved: function f(x: string[] | string[][]): string[][] { return Array.isArray(x[0]) ? x : [x]; } Upon inspection, it appears that the return value will constantly ...

What is the best way to implement useAsync (from the react-async-hook library) using TypeScript?

Currently, I am utilizing react-async-hook to retrieve API data within a React component. const popularProducts = useAsync(fetchPopularProducts, []); The fetchPopularProducts() function is an asynchronous method used to make API calls using fetch: export ...

Struggling to develop a Singleton AngularJS Service?

I am in the process of creating a Singleton AngularJS service using the 4th method. The structure of my service is as follows: provider('SocketService', { socket: null, // methods used within the config() of a module connect: functi ...

The carousel feature in AngularJS's bootstrap is currently experiencing technical difficulties

SOLVED: Look at this Codepen link for the correct code: Codepen Why is my angular bootstrap carousel displaying images stacked on top of each other without sliding? This is how I have set it up: HOME.HTML: <div id="slides_control"> <div> ...

Leverage the power of function overloading in TypeScript for efficient code

How can function overloading be reused effectively in TypeScript? Consider a scenario where a function is overloaded: function apply(value: number): number; function apply(value: string): string; function apply(value: any): any { return value; } No ...

How can we use tsyringe (a dependency injection library) to resolve classes with dependencies?

I seem to be struggling with understanding how TSyringe handles classes with dependencies. To illustrate my issue, I have created a simple example. In my index.tsx file, following the documentation, I import reflect-metadata. When injecting a singleton cl ...

Issue with ng-disabled not functioning properly for href tag within list item

Is there a way to prevent clicking on the <a> tag within a list item in a UI list so that the associated <div> is not displayed when clicked (excluding the last list item)? I have attempted using ng-disabled directly on the list item attribute ...

Having trouble with `$resource` in AngularJs but everything seems to be working fine with `$http`. Wondering how to transfer the parameters used in `$http`

Having some trouble posting image information to the backend. I attempted using $resource, but it didn't work. However, when I switched to using $http, it seemed to work fine. The issue is that I need to apply additional parameters to $http, and I&apo ...

Tips for choosing a visible element in Protractor while using AngularJS

I am working on a Single Page Application that contains multiple divs with the same class. My goal is to have protractor identify the visible div and then click on it. However, I keep encountering the error Failed: element not visible, which leads me to be ...

Attention all controllers summoned from one AngularJS document

Having recently delved into the world of AngularJS and Ionic, I've exhaustively searched for solutions both on this forum and beyond. Despite my efforts, nothing seems to be working. My goal is to create an application with a homepage featuring a ser ...

Guide on implementing dynamic rowspan in tables using vue.js

I am trying to create a table similar to the one in the example photo. https://i.sstatic.net/fkXDx.png I attempted to connect rows using rowspan and wrote some code for it, but unfortunately, I encountered an error in the browser. To start with, here is ...

Transferring Live Information Between Two Controllers

How can I transfer the 'header' and 'content' from a controller's $scope element (specifically the 'header' and 'content') to another page that is redirected to upon clicking a button? The current setup involve ...

Repeating percentages displayed in a progress bar

I created a responsive progress bar, but the progress values are repeating. I only want the central value to be displayed. Any suggestions on how to fix this issue? DEMO <div id="tab1"> <dx-data-grid class="tableTask" [dataSource]="datas" ...

Angular 9: Subscribing triggering refreshing of the page

I've been working on an Angular 9 app that interacts with the Google Books API through requests. The issue I'm facing is that whenever the requestBookByISBN(isbn: string) function makes a .subscribe call, it triggers a page refresh which I' ...

What is the reason behind decorators needing to utilize apply(this) on a function?

I've been delving into the realm of JavaScript and exploring decorator code. One thing I've noticed is that when looking at decorator code like the example below, the input function always applies to 'this' even though it doesn't a ...

Exploring the process of selecting checkboxes in Angular 6

I'm currently learning Angular 6 and I have a requirement to mark checkboxes based on specific IDs from two arrays: this.skillArray = [ {ID: 1, name: "Diving"}, {ID: 2, name: "Firefighting"}, {ID: 3, name: "Treatment"}, ...

"Regardless of the circumstances, the ionic/angular service.subscribe event

Currently, while developing the login section of my Ionic app, I am encountering an issue with the getTokenAsObservable.subscribe() function. The main problem is that the function checks the token status when it is saved (by clicking the Login button) or ...

Is it possible to retrieve all mandatory attributes of a TypeScript object?

Is there a method or approach available that can retrieve all necessary properties from a TypeScript interface or an object? For instance, something along the lines of Object.getOwnPropertyDescriptors(myObject) or keyof T, but with the specific details o ...

Employing Multer and Express in conjunction with TypeScript

Overview Currently, I am working on a project that involves creating a user-friendly website where individuals can easily upload images. For this particular task, I have employed Node.js, React, Multer, and Typescript. Issue at Hand app.post('/admi ...