logo
down
shadow

cannot get the attribute of html tag in angular


cannot get the attribute of html tag in angular

By : Ayan Gupta
Date : November 21 2020, 11:01 PM
this one helps. Your code is not working as written because $element and $attrs are not injectable. As discussed in the comments, you can use a directive to get access to the attributes and reference the controller from the directive. This is not really the proper way to do this, but it can be made to work.
So your controller could expose a method that is used to provide it with the API value from the directive, like this:
code :
.controller("TestCtrl", function ($scope) {
    this.SetApi = function (api) {
    $scope.api = api;
  };
})
.directive("getApi", function () {
    return {
    controller: "TestCtrl",
    link: function (scope, element, attr, controller) {
      controller.SetApi(attr.api);
    }
  };
});


Share : facebook icon twitter icon
Angular: is it possible to bind value of attribute to other html attribute

Angular: is it possible to bind value of attribute to other html attribute


By : zhuyuqi
Date : March 29 2020, 07:55 AM
I wish this helpful for you Use the ng-style directive on the second element. You can set styling on the elements via object form, and is automatically updated when the value changes.
On page load, calculate the height of elem1 and set it to a scope variable, lets say:
code :
$scope.elemStyle = {
    height: calculated_elem1_height
}
Add HTML elements with custom angular directive and attribute into Angular Component

Add HTML elements with custom angular directive and attribute into Angular Component


By : An Li
Date : March 29 2020, 07:55 AM
seems to work fine changing the innerHTML in Angular is not a good Idea. You have to create a directive where you bring in an instance of Renderer2 to render the components you need. Please read the following Article => https://alligator.io/angular/using-renderer2/ Regards Michael
Angular - Update html attribute in root index.html

Angular - Update html attribute in root index.html


By : kostas
Date : March 29 2020, 07:55 AM
around this issue I think, it can be changed simply...
https://stackblitz.com/edit/angular-ih2drk?file=src%2Fapp%2Fapp.component.ts
code :
import { Component, Renderer2 } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  name = 'Angular 6';
  constructor(private renderer: Renderer2) {
    this.renderer.setAttribute(document.querySelector('html'), 'lang', 'tr');
  }
}

Angular 8: Custom HTML Attribute doesn't work inside component html

Angular 8: Custom HTML Attribute doesn't work inside component html


By : Saurabh Gupta
Date : March 29 2020, 07:55 AM
it fixes the issue I'll answer my question in case someone lands here with a similar situation.
The problem in my case was - for some strange reason the data-src attribute was not recognized by the "sayit_js_bg_image" css class on component load.
code :
<div class="sayit_title_container row sayit_js_height sayit_block_with_fimage" [attr.data-src]="assets/imgs/clipart/standard_post/back-1.jpg">
  //Other elements
</div>
ngAfterViewInit() {
    $(".sayit_title_container").each(function () {
      $(this).css('background-image', 'url(' + $(this).attr('data-src') + ')');
    });
  }
Angular: Can content of an HTML attribute accessed from within the same HTML tag?

Angular: Can content of an HTML attribute accessed from within the same HTML tag?


By : Rashed
Date : March 29 2020, 07:55 AM
I hope this helps you . This question is an Angular specific. , I have three ways to achieve the same goal.
Use ts variable
code :
<li [id]="id" 
    [className]="id == 'good' ? 'active' : '' ">
    Use ts variable
</li>
<li id="good" 
    #li
    [className]=" li.id == 'good' ? 'active' : '' ">
    Use template reference variable
</li>
<li id="good" class="good-css" >
    Use css selector
</li>
.good-css[id=good] {
  color: blue
}
Related Posts Related Posts :
  • Using $http inside my own service - variable does not persist
  • Define global variable with Typescript Angularjs in components
  • Angular UI-Router childs
  • What is scope of a variable inside ng-repeat block in angular js
  • Angular.Foreach in $firebaseObject
  • How to create a new instance of variables in AngularJs so that their values would be independent of the original one?
  • Is there a direct way to know to which view I am going in ionic?
  • How to write test-case for Directive with in Directive using jasmine
  • How to pass variables from an array to ng-repeat
  • Launch an android app from Ionic app
  • Email Validation with AngularJS 1.2.0
  • How to pass data from login page to OAuth 2.0 and then get it back?
  • AngularJS - always show two digits after comma
  • Angularjs: Sorting not working in ui-grid with CellTemplate data
  • How to put serial number for rows in data table according to pagination
  • Play Application Couldn't be Started
  • Video capture to not show in my gallery on phone
  • Angularjs: how to properly save a blob pdf file recieved from the server
  • Md-list in md-card is not adjusting
  • AngularJS posting data to DB - data gets entered but error is shown
  • req.body is undefined in express 4.13.1
  • UI routes not working
  • bootstrap panel with angular ng-repeat
  • AngularJS: Filter array by type
  • Why do we pass second parameter in angular.bootstrap() as an array?
  • Angular2 - using 3rd parety module's component
  • neocomplete autocompletion not working correctly with syntax files
  • Cordova Console Log when Beta Testing
  • Re-render NgRepeat based on user typed value input field
  • My app seems to generate wrong urls in html5 mode
  • How does quotes inside template expression work in angular1?
  • Angular Binding in Object Property
  • How to use ng if else in one html tag to derive the condition
  • Group and sum fields in ng-repeat
  • how to remove border around ion-toggle
  • Network plugin ngCodova don't work into controller
  • How to get data from form input
  • Handling promises in Ionic project
  • ng-repeat to handle both data as object and array
  • AngularJS - Summing filtered rows in table
  • AngularJS wrapping cordova permissions into a promise chain?
  • Angularjs: slick not working properly with custom directives
  • Angular 2 Error: (SystemJS) XHR error (404 Not Found)
  • "Error: [ng:areq] Argument 'HelloHell' is not a function, got undefined
  • How to prevent an a element's click event what bind by angular?
  • Angularjs to display 2 arrays from a json object in two different tabledata of a tablerow
  • using ng-if to make p appear if image is null
  • AngularJS: Auto-update the total price
  • Correct method to Redirect from $http.post in angularjs
  • Angularjs - unable to call web api service from another project of same solution - VS2015
  • AngularJS: Hide li element when it's clicked
  • What is wrong with my Typescript AngularJS 1.5 component?
  • Angular 2 Type Script
  • Directive attribute forces boolean to string
  • Custom login screen with Auth0 and AngularJS
  • Angularjs: Why does adding an authorization header cause a -1 status response?
  • AngularJS error while uploading the json file
  • How to programmatically check checkbox with dynamic model name?
  • Timezone offset not working in angular js date expression
  • Angular Js , Check substring in comma separated string in angular js
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com