Apply for Zend Framework Certification Training

AngularJs




In this blog we will see how to create filter 

Step 1  Filter will be created outside controller 
   myapp.filter('mydate', function ($filter) {
    return function (input)
    {
        if (input == null) {
            return "";
        }
        var dd = input.split(' ');
        var _date = $filter('date')(dd['0'], 'dd-MM-yyyy');
        return _date.toUpperCase();
    };
}); 

In this filter we have created an filter to change Date format 
received from Database using PHP and to Change Date Format at
FrontEnd 


myapp.filter('getFirstWord', function ($filter) {
        return function (input)
        {
            
            //content = content.substring(0, maxCharacters);
            var dd = input.split(' ');
            
            if(dd[0].length >=10)
            {
                return dd[0].substring(0, 10)+" "+"...";
            }
            if(dd[0].length <10)
            {
                return dd[0]+" "+"...";
            }
        };

    });                                    

< How to get response data from json to angularjs Angularjs Form Data Submit Using Php Mysql Example >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top