0

Am trying to replace all the spaces in a message variable with hyphen. For instance from "here is my message to be" to "here-is-my-message-to-be"

can someone help me

 .controller('postNotif',
                ['$scope', '$http', '$rootScope', function ($scope, $http, $rootScope) {
                        $rootScope.modal = [];
                        $rootScope.notification = {

                            messages: "here is my message to be",

                         link: timing
                        };

2 Answers 2

1

Using the replace function:

message.replace(/\s/g, "-");
Sign up to request clarification or add additional context in comments.

Comments

1

use this method on ur string variable

.replace(/ /g, "-");

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.