You can pass the model to the directive like this -
<div header showprofile="false" search="search">
<div class="searchView col-xs-12">
<input type="text" placeholder="Search" ng-model="search" />
</div>
</div>
Update your directive to accept it
.directive('header', function() {
function link(scope, element, attrs) {
scope.$watch(attrs.search, function(value) {
console.log(value);
});
}
return {
restrict: 'EA',
scope: {
showprofile: '=',
search: '=',
},
link: link
};
});
UPDATE Here is a fiddle.
Hope that helps.