MD Gosoddin MD Gosoddin - 1 year ago 158
AngularJS Question

How to used directive in angular

i copied some code from a project i understand complete project but i cofused wat is ".directive" if i chane any thing here the file is not uploding please helpme

Html code

<input type="file" name="attachment" data-ak-file-model="tutorial.attachment" />

Here if i change a single word in "akFileModel" during the run time file not uploding pleasse explain this portion i copied this from

.directive("akFileModel", ["$parse",
function ($parse) {
return {
restrict: "A",
link: function (scope, element, attrs) {
var model = $parse(attrs.akFileModel);
var modelSetter = model.assign;
element.bind("change", function () {
scope.$apply(function () {
modelSetter(scope, element[0].files[0]);

Answer Source

Read on how to name directive and use it in the HTML

.directive("akFileModelsam", ["$parse",


 <input type="file" name="attachment" class="form-control" data-ak-file-modelsam="tutorial.attachment" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download