简体   繁体   中英

How to create random rooms in Angular JS

I'm currently doing a chat app using angular js. And i came to the point where someone could create a new room. But of course like always i faced a problem, This one being a big one where i didn't understand how to attack it.

I need to create multiple rooms using random hashes like chattapp.com/somerandomhashroom I seriously am clueless on how to attack that problem.

Here is my cloud 9(Where i work on actual project), and here is the plunker i created. So i really need help.

Just create a random string like so:

function getRandomString(length) {
    var string = "";
    var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for (var i = 0; i < length; i++){
        string += characters.charAt(Math.floor(Math.random() * characters.length));
    }
    return string;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM