Skip to main content
added 112 characters in body; added 644 characters in body
Source Link
gyc
  • 4.4k
  • 6
  • 37
  • 55

A directive returns an object. Javascript code is put inside a link, compile or controller function.

https://docs.angularjs.org/guide/directive

Put your console.log in the appropriate place and it will run. (EDIT: I'm surprised the code is even ran in the middle of the directive... use link instead)

You forgot to register your module first.

(function () {
     'use strict';
      angular.module('WizmoApp', []);
      angular
        .module('WizmoApp')
        .directive('validNumber', function () {
             console.log("foo");
             return {
            }
         });
 })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="WizmoApp">
  <input type="text" class="form-control" name="Value" ng-model="listingVm.form.Value" required valid-number>
</div>

A directive returns an object. Javascript code is put inside a link, compile or controller function.

https://docs.angularjs.org/guide/directive

Put your console.log in the appropriate place and it will run.

A directive returns an object. Javascript code is put inside a link, compile or controller function.

https://docs.angularjs.org/guide/directive

Put your console.log in the appropriate place and it will run. (EDIT: I'm surprised the code is even ran in the middle of the directive... use link instead)

You forgot to register your module first.

(function () {
     'use strict';
      angular.module('WizmoApp', []);
      angular
        .module('WizmoApp')
        .directive('validNumber', function () {
             console.log("foo");
             return {
            }
         });
 })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="WizmoApp">
  <input type="text" class="form-control" name="Value" ng-model="listingVm.form.Value" required valid-number>
</div>

Source Link
gyc
  • 4.4k
  • 6
  • 37
  • 55

A directive returns an object. Javascript code is put inside a link, compile or controller function.

https://docs.angularjs.org/guide/directive

Put your console.log in the appropriate place and it will run.