Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="myApplication">
<head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
    <meta charset="utf-8">
    <title>$parse Service</title>
</head>
<body ng-controller="MyController">
<input type="text" ng-model="inName" ng-change="parseAgain()" placeholder="Enter some string">
<h1>{{studName}}</h1>
<input type="text" ng-model="inSubject" ng-change="parseOtherWay()" placeholder="Enter some string">
<h1>{{subjectName}}</h1>
</body>
</html>
 
    var myApplication = angular.module("myApplication", []);
    myApplication.controller("MyController",
            function($scope, $parse) {
                var student = {
                    name: "Sandeep",
                    subject: "Mathematics"
                };
                //appraoch 1 :using assign method.
                var getName = $parse('name'),
                    setName = getName.assign;
                $scope.parseAgain = function() {
                    $scope.studName = setName($scope, $scope.inName);
                };
                //appraoch 2 :using getter method
                var getSubject = $parse('subject');
                $scope.subjectName = getSubject(student);
                $scope.parseOtherWay = function() {
                    $scope.subjectName = getSubject({
                        subject: $scope.inSubject
                    });
                };
            });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
saan1984pro
0viewers