ng-messages without form

In this example below you will see how to do a ng-messages without form with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by 1kohei1, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 1kohei1 ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>ng-messages without form</title>
  
  
  <link rel='stylesheet prefetch' href='https://cdn.rawgit.com/angular/bower-material/v0.10.0/angular-material.css'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div ng-controller="AppCtrl" layout="column" class="inputdemoErrors" ng-app="MyApp">
    <div layout-padding>
      <md-input-container flex>
        <label>External Link</label>
        <input type="text" ng-model="sample" required/>
        <div ng-messages="{'required': !sample}">
          <div ng-message="required">Please enter the External Link</div>
        </div>
      </md-input-container>
    </div>

</div>
  <script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-messages.min.js'></script>
<script src='https://cdn.rawgit.com/angular/bower-material/v0.10.0/angular-material.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/1kohei1/ng-messages-without-form-NqBryQ */
.inputdemoErrors .inputErrorsApp {
  min-height: 48px; }


/*Downloaded from https://www.codeseek.co/1kohei1/ng-messages-without-form-NqBryQ */
angular.module('MyApp')
.controller('AppCtrl', function($scope) {

});

Comments