# angular undefined



## ste2425 (Oct 15, 2013)

Im writing an mvc app.

Im using angular Js for part of it and creating a date picker directive.

All the data binding is working great when i manually enter data into the text inputs however when the date picker sets them, from an external js file it doesn't update the data binding.

I believe this is because the change is made outside of the ng-controller. 

So in my external js file where i set the text box i called this :


```
var scope = angular.element($("#outer")).scope();
  scope.$apply(function(){
  Ctrl.value=fFormatDate(y,m,d);
})
```

However i now get the console error 'angular is not defined' yet i have included the angular js files in my application and using it successfully. 

I believe i can get the data binding to update if i can figure out how to call $apply from an external js file.

Thanks all


----------



## ste2425 (Oct 15, 2013)

Hi all i found a workaround. Im still looking for the 'proper' way of doing it but for the moment it works.

Instead of applying external changes to the actual text input through 'Control.Value()' I handed the function an instance of the scope from my directive and used the scope to apply changes directly the the 'databind attribute' (not sure of the technical name), 'scope.control = value' for example. Realise this is a bit of a duct tape fix but it gets it up and running till i can sort it 'properly'.


----------

