var app = angular.module("myApp", []);
app.controller("myController", function($scope, $location) {
$scope.url = "samar"
$scope.myHome = "balasore"
$scope.v3 = "Bangalore"
//$scope.fcuk= "hello from here"
//will take as string in html
})
app.directive("tab", function($interpolate) {
return {
restrict: "EA",
scope: {
first: "=",
second: "@"
},
require: 'ngModel',
// compile: function(tele, tattr) {
//in compile {{}} and two way binding variables will not be evaluated(oneway binding or direct)
//console.log(tattr.attr1 + tattr.first + tattr.second + tattr.attr2 + tattr.attr3)
//return {
link: function(scope, ele, attr, ctrl) {
//in link 'attr.fisrt' variable will not be evaluated
console.log(attr.attr1 + $interpolate(attr.first)(scope) + attr.second + attr.attr2 + attr.attr3)
//$watch works with interpolated string if its having one way binding with @
//first , it will evaluate
//second , it will evaluate(one way binding with @ <<---->>interpolated string)
//attr3 , it will not evaluate
scope.$watch("second", function(nv, ov) {
console.log("changes in $watch " + nv)
})
//$observe always works for interpolated string and rest else works with $watch
//first , it will not evaluate
//second , it will evaluate(interpolated string)
//attr3 , it will evaluate(interpolated string)
attr.$observe("second", function(value) {
console.log("changes in $observe " + value)
//alert("hi")
})
//console.log(ele.html())
},
//}
//},
template: "<div><input type='text' id='idfirst' ng-model='first'/><div>You are changing {{first}} and he stays at <input type='text' ng-model='second' id='idsecond'/><input type='button' id='btnDirec' value='Change Here'...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.