Skip to main content

Anjular Js Examples

Anjular Js Examples:


<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<!-- <span ng-app="">
<input type="text" ng-model="test">
{{test}}
</span> -->
<!-- <span ng-app="">
<input type="text" ng-model="koti">
<span ng-bind="koti"></span>
</span> -->


<!-- <div ng-app="" ng-init="location='bangalore'">
<p>Location is :<span ng-bind="location"></span></p>

</div>

<div ng-app="">
{{50-50}}
</div> -->




===========
<!-- <div ng-app="koti"  ng-controller="raogaru">
<p>name :<span><input type="text" ng-model="name" id="check"></span></p>
<p>location :<span><input type="text"  ng-model="loc"></span></p>   
fullname {{name+""+loc}}                           
</div>
<span id="checkto">Test </span> -->

<script>
// $('#check').click(function()
// {
    //alert("sam");
// var a = angular.module('koti',[]);
// a.controller('raogaru',function($scope)
// {
// $scope.name='kotesh';
// $scope.loc='rao';
// $('#check').click(function()
//  {
//     alert($(this).val());
//     });
// });
// // });

</script>


<!--
<div ng-app="" ng-init="x=3;y=56;z=99">
{{x+y-z}}
<span ng-bind="x+y"> </span>
</div>
 -->

<!--  <div ng-app="" ng-init="first='koti';last='rao'">

 <span ng-bind="first+last"></span>
 </div>
 -->
<!-- <div ng-app="" ng-init="sam={add:'bangalore',loc:'karnataka'}">
<span ng-bind='sam.add+sam.loc'></span>
</div> -->

<!-- <div ng-app="" ng-init="x=['koti','sam','anju']">

<span ng-bind="x[1]">

</div> -->

<!-- <div ng-app="" ng-init="sam='koti'">
<input type="textarea" ng-model="sam">
<span>{{sam}} </span>
</div> -->
<!-- <div ng-app="" ng-init="k=['sam','swati']">
<span ng-repeat="z in k">
{{z}}
</span>

</div> -->

<!-- <div ng-app="" ng-init="names=[{name:'koti',loc:'bng'},{name:'sam',loc:'mlg'}]">
<span ng-repeat="k in names">
{{k.name+','+k.loc}}
</div> -->



<!-- <div ng-app="testapp" ng-controller="sample">
<input type="text" ng-model="name">
<input type="text" ng-model="loc">
{{name+','+loc}}
</div>
 -->
<script>
// var my = angular.module('testapp',[]);
// my.controller('sample',function($scope){

// $scope.name = "koti";
// $scope.loc = "rao"
// });

</script>
<!-- <div ng-app="sample" ng-controller="testing">
<input type="text" ng-model="firstname">
<input type="text" ng-model="lastname">

{{full_name()}}
</div> -->

<script>
// var m = angular.module('sample',[])
// m.controller('testing',function($scope)
// {
// $scope.firstname = "koti";
// $scope.lastname ="raogaru";
// $scope.full_name = function()
// {
//     return $scope.firstname+","+$scope.lastname
// }

// });

</script>
<!-- <div ng-app="myapp" ng-controller="koti">
<input type="number" ng-model="pric">
<input type="number" ng-model="cost">
{{(pric*cost)| currency}}
</div>
 -->
<script>
// var a = angular.module('myapp',[]).controller('koti',function($scope)
// {
// $scope.pric= 12;
// $scope.cost =13;

// })

</script>

<!-- <div ng-app="" >
<input type="textarea" ng-model="name">
{{name | lowercase | uppercase | currency}}
</div> -->


<!-- <div ng-app>
<input type="text" ng-model="test">
{{test}}
</div> -->

<!-- <div ng-app="" ng-init="sample=['3','2','1']">

<span ng-bind="sample"></span>
<span ng-repeat="s in sample || filter:s |orderby:s">
{{s}}
</span>
</div> -->


<!-- <div ng-app="samantha" ng-controller="sample">
<span ng-repeat='x in names'>
{{ x.Name + ', ' + x.Country }}
</span>
</div> -->
<script>
// angular.module('samantha',[]).controller("sample",function($scope,$http)
// {
// $http.get("http://www.w3schools.com/angular/customers.php").success(function(response) {$scope.names = response.records;});
// });

</script>

<!-- <div ng-app="swathi" ng-controller="anushka">
<table>
<tr ng-repeat = "x in names | orderBy : 'Country'">
  <!--  <td> {{$index+1}}</td>
    <td> {{x.Name}} </td>
    <td>{{x.Country | uppercase}} </td> -->
<!-- <td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Name }}</td>
<td ng-if="$even">{{ x.Name }}</td>
<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Country }}</td>
<td ng-if="$even">{{ x.Country }}</td>
</tr>
</table>

</div> -->
<script>
// angular.module("swathi",[]).controller("anushka",function($scope,$http)
// {
// $http.get("http://www.w3schools.com/angular/customers.php").success(function(response)
// {
//     $scope.names = response.records;

//     // body...
// })
// })
</script>

<!-- <div ng-app="" ng-init="mySwitch=true">
<button ng-disabled="mySwitch">Click Me!</button>
<input type="checkbox" ng-model="mySwitch">
{{mySwitch}}
</div> -->

<!-- <div ng-app="">
<span ng-show="true"> Iam kotesh</span>
<span ng-show="false"> hello</span>
<span ng-hide="true"> Iam kotesh</span>
<span ng-hide="false"> hello</span>
</div> -->
<!-- <div ng-app="">
<button ng-click="count=count+1">welcome kotesh</button>{{count}}
</div>
 -->

<!--  <div ng-app="koti" ng-controller="rao">
<button ng-click="togle()">Button </button>
<p ng-show="disp">
<input type="text" ng-model="firstname">
<input type="text" ng-model="lastname">
</p>
 </div> -->
 <script>
//  angular.module("koti",[]).controller("rao",function($scope)
//  {
// $scope.firstname="kotesh";
// $scope.lastname = "rao";
// $scope.disp = true;
// $scope.togle = function() {
// $scope.disp = !$scope.disp;
// }
//  });

 </script>

<!--  <div ng-app="rao" ng-controller="test">
<form novalidate>
<input type="text" ng-model="user.first">
<input type="text" ng-model="user.second">
<button ng-click="reset()">Reset</button>
</form>
 </div> -->

 <script>
 // angular.module("rao",[]).controller("test",function($scope)
 // {
 // $scope.master = {first:"kotesh",second:"rao"};
 // $scope.user = angular.copy($scope.master)   
 // });
 </script>


 <form ng-app="test" ng-controller="userform" name="myForm" novalidate>
 <p>user
 <input type="text" name="user "ng-model="user" required>
 <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
  <span ng-show="myForm.user.$error.required">Username is required.</span>
 </p>
 <p>email
 <input type="emil" name="email" ng-model="email" required>
  <span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
  <span ng-show="myForm.email.$error.required">Email is required.</span>
  <span ng-show="myForm.email.$error.email">Invalid email address.</span>

 </p>
 <p>
 <input type="submit" ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
  myForm.email.$dirty && myForm.email.$invalid">
 </p>
 </form>
 <script>
var app = angular.module("test", []);
app.controller("userform", function($scope) {
    $scope.user = 'John Doe';
    $scope.email = 'john.doe@gmail.com';
});
</script>
</body>
</html>




Comments

Popular posts from this blog

Get the Current url in ruby on rails

request.refererrequest.fullpathrequest.fullpath.split("?")[0]request.referer or request.env['HTTP_REFERER'] your controller to get the referer url. 

--------------------
request.original_url
request.url
request.host_with_port
<link rel="canonical" href="<%= request.url %>" />
<%=request.path%>
How can I get the current absolute URL in my Ruby on Rails view?
The request.request_uri only returns the relative URL.
request.env['REQUEST_URI']

 For Rails 3.2 or Rails 4 you should use request.original_url to get the current URL. More detail.

For Rails 3: You want "#{request.protocol}#{request.host_with_port}#{request.fullpath}", since request.url is now deprecated.

For Rails 2: You want request.url instead of request.request_uri. This combines the protocol (usually http://) with the host, and request_uri to give you the full address

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).?

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).) In rails?


1)change the gemfile in mysql version
 gem 'mysql2'

2)Change to mysql2 version
 gem 'mysql2','0.3.20'

Active Scaffold : Add radio buttons to your form ruby on rails ?

Active Scaffold : Add radio buttons to your form ruby on rails ?

The way to add radio buttons to your active scaffold create/update from is as shown below

#Controller

class UsersController < ApplicationController
active_scaffold :user do |config|
config.label = “Users”
config.columns = [:name, :gender]
config.columns[:gender].form_ui = :radio
config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]
end
end