What’s the meaning of require: ‘ngModel’?

[Origin]: https://stackoverflow.com/questions/20930592/whats-the-meaning-of-require-ngmodel

This is the HTML for my directive:

<textarea data-modal="modal" data-mydir ng:model="abc"></textarea>

In my directive I have this:

return {
        require: 'ngModel',
        replace: true,
        scope: {
            modal: '=modal',
            ngModel: '=',
            pid: '=pid'

Can someone tell me, what’s the significance of require: ‘ngModel’ ? I see this in many different directives. Could I call this data-modal?

I am confused because when I change it to data-modal I get a message from Angular saying

Controller 'ngModel', required by directive 'textarea', can't be found!

Tried to Load Angular More Than Once

[Origin]: https://stackoverflow.com/questions/22595878/tried-to-load-angular-more-than-once

This could be a number of issues: essentially it’s a problem of routeProvider not finding a file and recursively loading the default.

For me, it turned out that it wasn’t minification but concatenation of the js that caused the problems.

angular.module('myApp').config(['$routeProvider', function ($routeProvider) {
      .when('/', {
        templateUrl: 'views/listing.html',
        controller: 'ListingCtrl'
        redirectTo: '/'
  }]).constant('FIREBASE_URL', 'something');

You’ll notice that if the app can’t find a file (i.e., otherwise), then it will redirect to the root, which in this case loads the templateUrl. But if your templateUrl is wrong, then it will cause a recursion that reloads index.html loading angular (and everything else) over and over.

In my case, grunt-concat caused the templateUrl to be wrong after build, but not before.

I had the same issue, The problem was the conflict between JQuery and Angular. Angular couldn’t set the full JQuery library for itself. As JQLite is enough in most cases, I included Angular first in my web page and then I loaded Jquery. The error was gone then.

Making a div vertically scrollable using CSS

[Origin]: https://stackoverflow.com/questions/9707397/making-a-div-vertically-scrollable-using-css


<div id="" style="overflow:scroll; height:400px;>

 Run code snippet

gives a div that the user can scroll in both in horizontally and vertically. How do I change it so that the div is only scrollable vertically?

You have it covered aside from using the wrong property. The scrollbar can be triggered with any property overflowoverflow-x, or overflow-y and each can be set to any of visiblehiddenscrollauto, or inherit. You are currently looking at these two:

  • auto – This value will look at the width and height of the box. If they are defined, it won’t let the box expand past those boundaries. Instead (if the content exceeds those boundaries), it will create a scrollbar for either boundary (or both) that exceeds its length.
  • scroll – This values forces a scrollbar, no matter what, even if the content does not exceed the boundary set. If the content doesn’t need to be scrolled, the bar will appear as “disabled” or non-interactive.

If you always want the vertical scrollbar to appear:

You should use overflow-y: scroll. This forces a scrollbar to appear for the vertical axis whether or not it is needed. If you can’t actually scroll the context, it will appear as a”disabled” scrollbar.

If you only want a scrollbar to appear if you can scroll the box:

Just use overflow: auto. Since your content by default just breaks to the next line when it cannot fit on the current line, a horizontal scrollbar won’t be created (unless it’s on an element that has word-wrapping disabled). For the vertical bar,it will allow the content to expand up to the height you have specified. If it exceeds that height, it will show a vertical scrollbar to view the rest of the content, but will not show a scrollbar if it does not exceed the height.

How to remove currency symbol in AngularJS

[Origin]: https://stackoverflow.com/questions/31174600/how-to-remove-currency-symbol-in-angularjs

Can anybody tell how to remove the currency symbol in AngularJS?

value = $filter('currency')(value);

I am getting a dollar symbol. I want to remove it.

Just pass empty string as second argument to the filter function.

value = $filter('currency')(value, "");

Also you can inject currencyFilter itself. You do not have to derive it from the filter Factory, with that you would just do:

value = currencyFilter(value, "");

Note the syntax:

$filter('currency')(amount, symbol, fractionSize)

ARIA: Attribute ” aria-label “, required for accessibility, is missing on node

[Origin]: https://github.com/textAngular/textAngular/issues/1446

when using with angular material it shows the warning about aria label
ARIA: Attribute " aria-label ", required for accessibility, is missing on node:

<textarea id="taHtmlElement8316965102261715" ng-show="showHtml" ta-bind="ta-bind" ng-model="html" class="ng-pristine ng-untouched ng-valid ng-scope md-input ta-bind ta-html ta-editor form-control ng-empty ng-hide" rows="1" aria-hidden="true" aria-invalid="false" style="height: 0px;"></textarea>

where we have to add aria attribute in textangular directive

I Resolved this issue by adding the aria-label attribute.


if you have multiple fields and you want to ignore the issue in your application. Try to set $mdAriaProvider.disableWarnings();

app.config(function($mdAriaProvider) {
   // Globally disables all ARIA warnings.

Solution to your problem: you have to add attribute to your input, select, Textarea tags
Example : <textarea aria-label="Your Field Lable name"></textarea>

Angular: what is filterFilter

[Origin]: https://stackoverflow.com/questions/36702123/angular-what-is-filterfilter

i am new in angular and i am bit familiar with filter word but what is filterFilter word and usage in angular. just come across a code below from this url https://stackoverflow.com/a/22704140/6188148.

see the code

angular.module('FilterInControllerModule', []).
    controller('FilterController', ['filterFilter', function(filterFilter) {
      this.array = [
        {name: 'Tobias'},
        {name: 'Jeff'},
        {name: 'Brian'},
        {name: 'Igor'},
        {name: 'James'},
        {name: 'Brad'}
      this.filteredArray = filterFilter(this.array, {name:'Igor'});

just tell me what is filterFilter ? is it any built-in filter ?

Angular filter names just have to end with Filter in order to be a valid filter.