In my code, when the index is 0, I am supplying the second template which contains the word as arif. With the rest I am supplying the first template which doesn't have the word arif.

I got this result as a result of a posted question, but I am not satisfied with it because of its length.

// Code goes here
"use strict";
angular.module('tcpApp', [])
.controller('MainCtrl', function($scope) {

.directive('programName', function ( $compile ) {
        return {
            restrict    : 'AE',
            replace     : true,
            scope       : {

            link        : function (scope, element, attr) {
                            scope.callMe = function () {

                            var getTemplate = function( index ) {
                              return Number(index) ? '<h2 class="que t{{index}}" ng-click=callMe()>{{name}}</h2>' : '<h2 class="que t{{index}}" ng-click=callMe()>{{name}}arif</h2>';



Live Demo to Play


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.