0

For eg.

<h3>www.domain.com</h3>

should be converted to

<a>www.domain.com</a>

under certain logic

1
  • 2
    Please include some code you have tried :) Commented Jun 29, 2016 at 11:20

2 Answers 2

1

If you want to do it the angular way you can use ng-show/ng-hide/ng-if. e.g.

in controller (Just an example, change this so your logic sets true/false to show/hide):

$scope.showLink = true;

in view:

<h3 ng-if="!showLink">www.domain.com</h3>
<a ng-if="showLink">www.domain.com</a>
Sign up to request clarification or add additional context in comments.

Comments

1

Here's another example which could come in handy if you were to have to toggle between more than just two elements.

js

app.controller('MainCtrl', function($scope) {
  $scope.expression = "link";
});

html

  <body ng-controller="MainCtrl">
    <div ng-switch="expression">
      <h3 ng-switch-when="text">www.domain.com</h3>
      <a ng-switch-when="link">www.domain.com</a>
    </div>
    <button ng-click="expression = (expression === 'text' ? 'link' : 'text')">Toggle</button>
  </body>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.